Part Number Hot Search : 
MJE170 BU207 EA09761 M67749 FZT65 NJM2100D STV3012 BUS133A
Product Description
Full Text Search
 

To Download N79E352RAPG Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  preliminary n 79 e352/n79e352r data s heet 8- bit microcontrolle r - 1 - table of contents - 1. general description .......................................................................................................... 4 2. features ................................................................................................................................. 5 3. parts infor mation list ..................................................................................................... 6 3.1 lead free (rohs) parts information list ......................................................................... 6 4. pin configurations ............................................................................................................. 7 5. pin descriptions .................................................................................................................. 9 6. functional descripti on .................................................................................................. 11 6.1 on - chip flash eprom ................................................................................................. 11 6.2 i/o ports ........................................................................................................................ 11 6.3 serial i/o ....................................................................................................................... 11 6.4 timers ........................................................................................................................... 11 6.5 interrupts ....................................................................................................................... 11 6.6 data pointers ................................................................................................................ 11 6.7 architecture ................................................................................................................... 11 6.8 power management ...................................................................................................... 12 7. memory organization ...................................................................................................... 13 7.1 program memory (on - chip flash) ................................................................................. 13 7.2 data memory ................................................................................................................. 14 7.3 scratch - pad ram and register map ............................................................................ 14 8. special function reg isters .......................................................................................... 17 8.1 sfr location table ...................................................................................................... 17 8.2 sfr detail bit descriptions ........................................................................................... 21 9 . instruction .......................................................................................................................... 51 9.1 instruction timing .......................................................................................................... 58 9.2 movx instruction .......................................................................................................... 62 9.3 external data memory access timing .......................................................................... 63 9.4 wait state control signal .............................................................................................. 66 10. power management .......................................................................................................... 67 10.1 idle mode ...................................................................................................................... 67 10.2 economy mode ............................................................................................................. 67 10.3 power down mode ........................................................................................................ 68
preliminary n 79 e352/n79e352r data sheet - 2 - 11. reset conditions ............................................................................................................... 69 11.1 sources of reset ............................................................................................................ 69 11.2 reset state ................................................................................................................... 69 12. programmable timers/ counters ................................................................................ 71 12.1 timer/counters 0 & 1 .................................................................................................... 71 12.2 time - base select ion ..................................................................................................... 71 12.3 timer/counter 2 ............................................................................................................ 74 13. nvm memory ......................................................................................................................... 78 13.1 operation ...................................................................................................................... 78 14. watchdog timer ................................................................................................................. 80 15. uart serial port ................................................................................................................ 82 15.1 mode 0 .......................................................................................................................... 82 15.2 mode 1 .......................................................................................................................... 83 15.3 mode 2 .......................................................................................................................... 84 15.4 mode 3 .......................................................................................................................... 87 15.5 framing error detection ................................................................................................ 88 15.6 multiprocessor communications ................................................................................... 88 16. i2c seria l port .................................................................................................................... 90 16.1 i2c bus ......................................................................................................................... 90 16.2 the i2c control registers: ........................................................................................... 91 16. 3 modes of operation ...................................................................................................... 93 16.4 data transfer flow in five operating modes ............................................................... 94 17. timed access protect ion ............................................................................................. 100 18. interrupts ......................................................................................................................... 102 18.1 interrupt sources ........................................................................................................ 102 18.2 priority level structure ................................................................................................ 103 18.3 interrupt response time ............................................................................................ 105 18.4 interrupt inputs ............................................................................................................ 105 19. keyboa rd function ......................................................................................................... 106 20. input capture ................................................................................................................... 108 21. pulse width modulate d outputs (pwm) ................................................................. 110 22. i/o port ................................................................................................................................. 111 22.1 quasi - bidirectional output configuration .................................................................... 111 22.2 open drain output configuration ............................................................................... 112 22.3 push - pull output configuration ................................................................................... 113 22.4 input only mode .......................................................................................................... 113
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 3 - revision a0 6 2 3. oscillator .......................................................................................................................... 115 23.1 on - chip rc oscillator option ..................................................................................... 115 23.2 external clock input option ........................................................................................ 115 23.3 cpu clock rate select ............................................................................................... 116 24. power monitoring .......................................................................................................... 117 24.1 power on detect ......................................................................................................... 117 24.2 brownout detect and reset ........................................................................................ 117 25. icp(in - circuit program) fla sh program ................................................................. 119 2 6. config bits ......................................................................................................................... 120 26.1 config0 .................................................................................................................... 120 26.2 config1 .................................................................................................................... 121 27. electri cal characteristics ....................................................................................... 123 27.1 absolute maximum ratings ........................................................................................ 123 27.2 d.c. characteristics .................................................................................................... 124 27.3 a.c. characteristics .................................................................................................... 125 27.4 rc osc and ac characteristics .................................................................... 130 27.5 typical application circuit ........................................................................................... 130 28. package dimensions ....................................................................................................... 131 28.1 40- pin dip ................................................................................................................... 131 28.2 44- pin plc c ................................................................................................................ 132 28.3 44- pin pqfp ............................................................................................................... 133 28.4 48- pin lqfp ................................................................................................................ 134 29. revision his tory .............................................................................................................. 135
preliminary n 79 e352/n79e352r data sheet - 4 - 1. general description the n79e352(r) is an 8 - bit turbo 51 microcontroller which has flash eprom program mable hardware writer. the instruction set of the n79e352(r) is fully compatible with the standard 805 2 . the n79 e352(r) contain s a 8k bytes of main f lash eprom; a 256 bytes of ram; 128 bytes nvm data f lash eprom; three 16- bit timer/counters ; 2 - cha nnel 8 - bit pwm; 1 - channel uart and 1 additional input capture . these peripherals are supported by 1 1 interrupt sources fou r - level interrupt capability. to facilitate programming and verification, the f lash eprom inside the n79e352(r) allow s the program memory to be programmed and read electronically. once the code is confirmed, the user can protect the code for security. n79e 352(r) is designed for cost effective applications which can serve industrial devices, and other low power applications .
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 5 - revision a0 6 2. features ? fully static design 8 - bit turbo 51 cmos microcontroller up to 24 mhz when vdd=4.5v to 5.5v, 12mhz when vdd=2.7v to 5.5v , and 4mhz when vdd=2.4v to 5.5v. ? 8k bytes of ap flash eprom, with external writer programmable mode. ? 256 bytes of on - chip ram. ? 128 bytes nvm data flash eprom for customer data storage used and 10k writer cycles . ? instruction - set compatible with m cs - 51. ? on - chip configurable rc oscillator: 22.1184mhz/11.0592mhz (s electable by config bit) with 2% accuracy , at 5 v voltage and 25 c condition. ( 2% accuracy is only for n79e352r.) ? three 16- bit timer/counters. ? one input capture. ? 11 interrupt source with four levels of priority. ? one enhanced full duplex serial port with framing error detection and automatic address recognition. ? 4 outputs mode and ttl/schmitt trigger selectable port. ? programmable watchdog timer with 20khz internal rc clock can wake - up the power down mo de, and have very low power under 10ua at 5v. ? two - channe l 8 - bit pwm. ? one i2c communication port. ? dual 16 - bit data pointers. ? software programmable access cycle to external ram/peripherals. ? eight keypad s interrupt inputs with shar ing the same in terrupt so urce . ? led drive capability (20ma) on all port pins , total 100ma . ? low voltage ( 3 levels) detect ion interrupt and reset. ? industrial temperature grade - 40 o c~85 o c . ? packages: ? lead free (rohs) dip40 : n79e352 r a d g ? lead free (rohs) plcc44 : n79e352 r apg ? lead free (r ohs) pqfp44 : n79e352 r afg ? lead free (rohs) lqfp 48: n79e352 r a l g ? lead free (rohs) dip40 : n79e352 a d g ? lead free (rohs) plcc44 : n79e352 apg ? lead free (rohs) pqfp44 : n79e352 afg ? lead free (rohs) lqfp 48: n79e352a l g -
preliminary n 79 e352/n79e352r data sheet - 6 - 3. parts information li st 3.1 lead free (rohs) parts inf ormation list part no. eprom flash size ram nvm flash eprom internal rc oscillator accuracy 1 package n79e352 r a d g 8kb 256b 128b 22.1184mhz 2% dip - 40 p in n79e352 r apg 8kb 256b 128b 22.1184mhz 2% plcc - 44 p in n79e352 r afg 8kb 256b 128b 22.1184mhz 2% pqf p - 44 p in n79e35 2ral g 8kb 256b 128b 22.1184mhz 2% lqfp - 48 p in n79e352 a d g 8kb 256b 128b 22mhz 2 5 % dip - 40 p in n79e352 apg 8kb 256b 128b 22mhz 2 5 % plcc - 44 p in n79e352 afg 8kb 256b 128b 22mhz 2 5 % pqfp - 44 p in n79e352al g 8kb 256b 128b 22mhz 2 5 % lqfp - 48 p in table 3 - 1 : lead free (rohs) parts information lis t note: 1. factory calibration condition: v dd = 5.0v 10%, ta = 2 5 c
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 7 - revision a0 6 4. pin configurations 8 1 8 6 7 10 9 12 11 14 13 16 15 17 5 4 3 2 1 4 4 4 3 4 2 4 1 4 0 38 39 36 37 34 35 32 33 30 31 29 1 9 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 p 1 . 6 pwm 1 , p 1 . 5 rst p 1 . 7 p 4 . 3 rxd , p 3 . 0 txd , p 3 . 1 t 0 , p 3 . 4 t 1 , p 3 . 5 s c l , p 1 . 3 s d a , p 1 . 2 p w m 0 , p 1 . 4 t 2 e x , p 1 . 1 t 2 , p 1 . 0 k b 0 , a d 0 , p 0 . 0 p 4 . 2 k b 1 , a d 1 , p 0 . 1 k b 2 , a d 2 , p 0 . 2 k b 3 , a d 3 , p 0 . 3 v d d ale p 0 . 7 , ad 7 , kb 7 p 4 . 1 p 0 . 6 , ad 6 , kb 6 p 0 . 5 , ad 5 , kb 5 p 0 . 4 , ad 4 , kb 4 p 2 . 5 , a 13 p 2 . 6 , a 14 p 2 . 7 , a 15 x t a l 2 , p 5 . 2 x t a l 1 , p 5 . 1 v s s p 2 . 1 , a 9 p 4 . 0 p 2 . 2 , a 1 0 p 2 . 3 , a 1 1 p 2 . 4 , a 1 2 p 2 . 0 , a 8 plcc 44 - pin int 0 , p 3 . 2 p 3 . 7 , r d int 1 , p 3 . 3 psen ea p 3 . 6 , w r 10 9 12 11 14 13 16 15 17 p 1 . 6 pwm 1 , p 1 . 5 rst p 1 . 7 rxd , p 3 . 0 txd , p 3 . 1 t 0 , p 3 . 4 t 1 , p 3 . 5 int 0 , p 3 . 2 int 1 , p 3 . 3 2 1 4 3 6 5 8 7 scl , p 1 . 3 sda , p 1 . 2 pwm 0 , p 1 . 4 t 2 ex, p 1 . 1 t 2 , p 1 . 0 19 18 20 wr , p 3 . 6 rd , p 3 . 7 p 5 . 0 , xtal 2 p 5 . 1 , xtal 1 38 39 36 37 34 35 32 33 30 31 29 28 40 26 27 24 25 22 23 21 p 2 . 1 , a 9 p 2 . 2 , a 10 p 2 . 3 , a 11 p 2 . 4 , a 12 p 2 . 0 , a 8 p 2 . 5 , a 13 p 2 . 6 , a 14 p 2 . 7 , a 15 ale p 0 . 7 , ad 7 , kb 7 p 0 . 6 , ad 6 , kb 6 p 0 . 5 , ad 5 , kb 5 p 0 . 4 , ad 4 , kb 4 psen ea p 0 . 0 , ad 0 , kb 0 p 0 . 1 , ad 1 , kb 1 p 0 . 2 , ad 2 , kb 2 p 0 . 3 , ad 3 , kb 3 vdd d i p 4 0 - p i n v s s
preliminary n 79 e352/n79e352r data sheet - 8 - 8 1 2 3 7 7 10 9 11 4 4 4 3 4 2 4 1 4 0 3 9 3 8 3 6 3 5 3 4 32 33 30 31 28 29 26 27 24 25 23 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 0 2 1 2 2 p 1 . 6 rst p 1 . 7 rxd , p 3 . 0 txd , p 3 . 1 t 0 , p 3 . 4 t 1 , p 3 . 5 t 2 e x , p 1 . 1 t 2 , p 1 . 0 v d d ale p 4 . 1 p 2 . 5 , a 13 p 2 . 6 , a 14 p 2 . 7 , a 15 v s s p 2 . 1 , a 9 p 4 . 0 p 2 . 2 , a 1 0 p 2 . 3 , a 1 1 p 2 . 0 , a 8 l qfp 44 - pin int 0 , p 3 . 2 p 3 . 7 , r d int 1 , p 3 . 3 psen ea p 3 . 6 , w r 2 1 4 3 5 6 p 4 . 3 p 4 . 2 2 4 4 1 4 3 6 5 8 7 10 9 11 4 8 4 2 4 1 4 0 3 9 3 8 3 7 32 33 30 31 28 29 26 27 25 1 3 1 4 1 5 1 6 1 8 1 9 2 0 2 1 2 2 p 2 . 7 , a 15 psen ale ea p 4 . 1 p 2 . 4 , a 1 2 p 2 . 3 , a 1 1 p 2 . 2 , a 1 0 p 2 . 1 , a 9 p 3 . 7 , / r d p 3 . 6 , / w r p 4 . 3 int 0 , p 3 . 2 int 1 , p 3 . 3 t 0 , p 3 . 4 t 1 , p 3 . 5 p 1 . 6 p 1 . 7 rst p 2 . 0 , a 8 p 4 . 0 v s s 12 1 7 2 3 2 4 34 35 36 4 6 4 7 4 3 4 5 p 2 . 6 , a 14 p 2 . 5 , a 13 nc v d d p 4 . 2 t 2 , p 1 . 0 t 2 e x , p 1 . 1 p 3 . 1 p 3 . 0 n c nc n c lqfp 48 - pin p 0 . 7 , ad 7 , kb 7 p 0 . 6 , ad 6 , kb 6 p 0 . 5 , ad 5 , kb 5 p 0 . 4 , ad 4 , kb 4 k b 0 , a d 0 , p 0 . 0 k b 1 , a d 1 , p 0 . 1 k b 2 , a d 2 , p 0 . 2 k b 3 , a d 3 , p 0 . 3 pwm 1 , p 1 . 5 s c l , p 1 . 3 s d a , p 1 . 2 p w m 0 , p 1 . 4 x t a l 2 , p 5 . 2 x t a l 1 , p 5 . 1 pwm 1 , p 1 . 5 s c l , p 1 . 3 s d a , p 1 . 2 p w m 0 , p 1 . 4 x t a l 2 , p 5 . 2 x t a l 1 , p 5 . 1 k b 0 , a d 0 , p 0 . 0 k b 1 , a d 1 , p 0 . 1 k b 2 , a d 2 , p 0 . 2 k b 3 , a d 3 , p 0 . 3 p 0 . 7 , ad 7 , kb 7 p 0 . 6 , ad 6 , kb 6 p 0 . 5 , ad 5 , kb 5 p 0 . 4 , ad 4 , kb 4 p 2 . 4 , a 1 2
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 9 - revision a0 6 5. pin description s symbol alternate function 1 alternate function 2 type descriptions ea i external access enable : this pin forces the processor to execute out of external rom. it should be kept high to access internal rom. the rom addr ess and data will not be present on the bus if ea pin is high and the program counter is within internal rom area. otherwise they will be present on the bus. psen o program store enable : psen enables the external rom data onto the port 0 address/data bus during fetch and movc operations. when internal rom access is performed, no psen strobe signal outputs from this pin. ale o address latch enable : ale is used to enable the address latch that sep a rates the address from the data on port 0. xtal1 p5.1 i/o crystal1 : this is the crystal oscillator input. this pin may be driven by an external clock or configurable i/o pin, p5.1. xtal2 p5.0 i/o crystal2 : this is the crystal oscillator outp ut. it is the inversion of xtal1. also a configurable i/o pin, p5.0. vdd p power supply : supply voltage for operation. vss p ground : ground potential. rst reset: a high on this pin for two machine cycles while the oscillator is running resets the device. p0.0 kb0 ad0 i/o port0: support 4 mode output and 2 mode input. multifunction pins for ad0 - 7 and kb0 - 7. p0.1 kb1 ad1 i/o p0.2 kb2 ad2 i/o p0.3 kb3 ad3 i/o p0.4 kb4 ad4 i/o p0.5 kb5 ad5 i/o p0.6 kb6 ad6 i/o p0.7 kb7 ad7 i/o p1.0 t2 i/o port1: support 4 mode output and 2 mode input. multifunction pins for sda & scl (i2c), t2, t2ex and pwm0 - 1. p1.1 t2ex i/o p1.2 sda i/o p1.3 scl i/o p1.4 pwm0 i/o p1.5 pwm1 i/o p1.6 icpdat i/o p1.7 icpclk i/o
preliminary n 79 e352/n79e352r data sheet - 10 - p2.0 a8 i/o port2: support 4 mode output and 2 mode input. multifunction pins for a8 - a15,. p2.1 a9 i/o p2.2 a10 i/o p2.3 a11 i/o p2.4 a12 i/o p2.5 a13 i/o p2.6 a14 i/o p2.7 a15 i/o p3.0 rxd i/o port3: support 4 mode output and 2 mode input. multifuncti on pins for rxd & txd (uart), /int0, /int1, t0, t1, /wr and /rd. p3.1 txd i/o p3.2 /int0 i/o p3.3 /int1 i/o p3.4 t0 i/o p3.5 t1 i/o p3.6 /wr i/o p3.7 /rd i/o p4.0 i/o port4: quasi output with internal pull up. p4.1 i/o p4.2 i/o p4.3 i/o * note: type i: input, o: output, i/o: bi - directional. in application if any pins need external pull - up, it is recommended to add a pull - up resistor (10 k ? ) between pin and power (v dd ) instead of directly wiring pin to v dd for enhancing emc.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 11 - revision a0 6 6. functional descripti on n79e352(r) architecture consist of a 4t 80 51 core controller surrounded by various registers, 8k byte s flash eprom, 256 bytes of ram, 128 bytes nvm data flash eprom; three timer/counters, one uart serial port, one i 2 c serial p ort, eight key board interrupt input, 2 - channel pwm with 8 - bit counter and flash eprom program by writer . 6.1 on - chip flash eprom n79e352(r) include s one 8k bytes of main f lash eprom for application program which need writer to program the flash e prom. 6.2 i/o port s n79e352(r) ha s four 8 - bit, one 4 - bit port and one 2- bit port , with at least 36 i/o pins . all ports (except port 4) can be used as four outputs mode when it may set by pxm1.y and pxm2.y registers, it has strong pull - ups and pull - downs, and does not need a ny external pull - ups. otherwise it can be used as general i/o port as open drain circuit. all ports can be used bi - directional and these are as i/o ports. these ports are not true i/o, but rather are pseudo - i/o ports. this is because these ports have stron g pull - downs and weak pull - ups. 6.3 serial i/o n79e352(r) has one uart serial port that is functionally similar to the serial port of the original 805 2 family. however the serial port on n79e352(r) can operate in different modes in order to obtain timing simi larity as well. the serial port has the enhanced features of automatic address recogni tion and frame error detection. 6.4 timers the device has total three 16 - bit timers; two 16 - bit timers that have functions similar to the timers of the 8052 family, and third timer is capable to function as timer and also provide capture support. when used as timers, user has a choice to set 12 or 4 clocks per count that emulates the timing of the original 8052. each timer?s count value is stored in two sfr locations that can be written or read by software. there are also some other sfrs associated with the timers that control their mode and operation. 6.5 interrupts the interrupt structure in n79e352(r) is slightly different from that of the standard 8052. due to the presence of additional features and peripherals, the number of interrupt sources and vectors has been increased. 6.6 data pointers the original 8052 had only one 16 - bit data pointer (dpl, dph). in the n79e352(r) , there is an additional 16 - bit data pointer (dpl1, dph1). th is new data pointer uses two sfr locations which were unused in the original 8052. in addition there is an added instruction, dec dptr (op - code a5h), which helps in improving programming flexibility for the user. 6.7 a rchitecture n79e352(r) is based on the sta ndard 80 52 device. it is built around an 8 - bit alu that uses internal registers for temporary storage and control of the peripheral devices. it can execute the standard 80 5 2 instruction set.
preliminary n 79 e352/n79e352r data sheet - 12 - 6.7.1 alu the alu is the heart of the n79e352(r) . it is responsible fo r the arithmetic and logical functions. it is also used in decision making, in case of jump instructions, and is also used in calculating jump addresses. the user cannot directly use the alu, but the instruction decoder reads the op - code, decodes it, and s equences the data through the alu and its associated registers to generate the required result. the alu mainly uses the acc which is a special function register (sfr) on the chip. another sfr, namely b register is also used in multiply and divide instructi ons. the alu generates several status signals which are stored in the program status word register (psw). 6.7.2 accumulator the accumulator (acc) is the primary register used in arithmetic, logical and data transfer operations in n79e352(r) . since the accumulato r is directly accessible by the cpu, most of the high speed instructions make use of the acc as one argument. 6.7.3 b register this is an 8 - bit register that is used as the second argument in the mul and div instructions. for all other instructions it can be use d simply as a general purpose register. 6.7.4 program status word: this is an 8 - bit sfr that is used to store the status bits of the alu. it holds the carry flag, the auxiliary carry flag, general purpose flags, the register bank select, the overflow flag, and t he parity flag. 6.7.5 scratch - pad ram n79e352(r) has a 256 byte s on- chip scratch - pad ram. th ese can be used by the user for temporary storage during program execution. a certain section of this ram is bit addressable, and can be directly addressed for this purpo se. 6.7.6 stack pointer n79e352(r) has a n 8 - bit stack pointer which points to the top of the stack. this stack resides in the scratch pad ram. hence the size of the stack is limited by the size of this ram. 6.8 power management like the standard 80c52, the n79e352( r) also has idle and power down modes of operation. the n79e352(r) provides a new economy mode which allow user to switch the internal clock rate divided by either 4, 64 or 1024. in the idle mode, the clock to the cpu core is stopped while the timers, seri al ports and interrupts clock continue to operate. in the power down mode, all the clock are stopped and the chip operation is completely stopped. this is the lowest power consumption state.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 13 - revision a0 6 7. memory organization n79e352(r) separate s the memory into two se parate sections, the program memory and the data memory. the program memory is used to store the instruction op - codes, while the data memory is used to store data or for memory mapped devices. 8k bytes on-chip code memory config 0 1fffh 2000h fc00h config 1 fc7fh 128b nvm data memory (movx) nvm data flash area fc1fh fc10h fc0fh fc00h page 0 page 1 page 7 page 2 page 3 page 4 page 5 page 6 (128b nvm, 16bytes/page) fc3fh fc30h fc2fh fc20h fc5fh fc50h fc4fh fc40h fc7fh fc70h fc6fh fc60h 0000h program memory space ffffh external program memory figure 7 - 1 : n79e352(r) memory map 7.1 program memory ( on- chip flash) the program memory on n79e352(r) can be up to 8 k bytes long. all instructions are fetched for execution from this memory area. the movc instruction can also access this memor y region.
preliminary n 79 e352/n79e352r data sheet - 14 - 7.2 data memory the n79e352(r) has nvm data memory of 128 bytes for customer? s data store u sed. th e nvm data memory ha s 8 pages area and each page has 16 bytes. the n79e352(r) can access up to 64kbytes of external data memory. this memory region i s acc essed by the movx instructions. for nvm s/w read access, user require to set ennvm bit, oth erwise, the access will goes to external data memory. n79e352(r) has the standard 256 bytes of on - chip scratchpad ram. this can be accessed either by direct add ressing or by indirect addressing. there are also some special function registers (sfrs), which can only be accessed by direct addressing. since the scratchpad ram is only 256 bytes, it can be used only when data contents are small. 7.3 scratch - pad ram and re gister map as mentioned before, n79e352(r) has separate program and data memory areas. the on - chip 256 bytes scratch pad ram is in addition to the external memory. there are also several special function registers (sfrs) which can be accessed by software. the sfrs can be accessed only by direct addressing, while the on - chip ram can be accessed by either direct or indirect addressing. indirect ram addressing direct & indirect ram addressing sfr direct addressing only 00h 7fh 80h ffh figure 7 - 2 : n79e352(r) ram and sfr memory map since the scratch - pad ram is only 256 bytes it can be used only when data contents are small. there are several other special purpose areas within the scratch - pad ram. these are illustrated in next figure.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 15 - revision a0 6 bank 0 bank 1 bank 2 bank 3 03 02 01 00 04 05 06 07 0b 0a 09 08 0c 0d 0e 0f 13 12 11 10 14 15 16 17 1b 1a 19 18 1c 1d 1e 1f 23 22 21 20 24 25 26 27 2b 2a 29 28 2c 2d 2e 2f 33 32 31 30 34 35 36 37 3b 3a 39 38 3c 3d 3e 3f 43 42 41 40 44 45 46 47 4b 4a 49 48 4c 4d 4e 4f 53 52 51 50 54 55 56 57 5b 5a 59 58 5c 5d 5e 5f 63 62 61 60 64 65 66 67 6b 6a 69 68 6c 6d 6e 6f 73 72 71 70 74 75 76 77 7b 7a 79 78 7c 7d 7e 7f direct ram indirect ram 00h 07h 28h 08h 0fh 10h 17h 18h 1fh 20h 21h 22h 23h 24h 25h 26h 27h 29h 2ah 2bh 2ch 2dh 2eh 2fh 30h 7fh 80h ffh figure 7 - 3 : scratch - pad ram
preliminary n 79 e352/n79e352r data sheet - 16 - 7.3.1 working registers there are four sets of working registers, each consisting of eight 8 - bi t registers. these are termed a s banks 0, 1, 2, and 3. individual registers within these banks can be directl y accessed by separate instructions. these individual registers are named as r0, r1, r2, r3, r4, r5, r6 and r7. however, at any one time n7 9 e352 can work with only one particular bank. the bank selection is done by setting rs1 - rs0 bits in the psw. the r0 a nd r1 registers are used to store the address for indirect accessing. 7.3.2 bit addressable locations the scratch - pad ram area from location 20h to 2fh is byte as well as bit addressable. this means that a bit in this area can be individually addressed. in addi tion some of the sfrs are also bit addressable. the instruction decoder is able to distinguish a bit access from a byte access by the type of the instruction itself. in the sfr area, any existing sfr whose address ends in a 0 or 8 is bit addressable. 7.3.3 stac k the scratch - pad ram can be used for the stack. this area is selected by the stack pointer (sp), which stores the address of the top of the stack. whenever a jump, call or interrupt is invoked the return address is placed on the stack. there is no restric tion as to where the stack can begin in the ram. by default however, the stack pointer contains 07h at reset. the user can then change this to any value desired. the sp will point to the last used value. therefore, the sp will be incremented and then addre ss saved onto the stack. conversely, while popping from the stack the contents will be read first, and then the sp is decreased.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 17 - revision a0 6 8. special function reg isters the n79e352(r) uses special function registers (sfrs) to control and monitor peripherals and thei r modes. the sfrs reside in the register locations 80 - ffh and are accessed by direct addressing only. some of the sfrs are bit addressable. this is very useful in cases where one wishes to modify a particular bit without changing the others. the sfrs that are bit addressable are those whose addresses end in 0 or 8. the n79e352(r) contains all the sfrs present in the standard 8052. however, some additional sfrs have been added. in some cases unused bits in the original 8052 have been given new functions. the list of sfrs is as follows. the table is condensed with eight locations per row. empty locations indicate that there are no registers at these addresses. when a bit or register is not implemented, it will read high. 8.1 sfr location table f8 ip1 ff f0 b ip1h f7 e8 eie kbl ports p5m1 p5m2 ef e0 acc c cl0 cch0 e7 d8 wdcon pwm0l pwm1l pwmcon1 df d0 psw pwmcon3 d7 c8 t2con t2mod rcap2l rcap2h tl2 th2 nvmcon nvmdat cf c0 i2con i2addr rommap pmr status nvmaddr ta c7 b8 ip0 sad en i2data i2status i2clk i2timer bf b0 p3 p0m1 p0m2 p1m1 p1m2 p2m1 p2m2 ip0h b7 a8 ie saddr af a0 p2 kbi auxr1 capcon0 capcon1 p4 a7 98 scon sbuf p3m1 p3m2 9f 90 p1 p5 97 88 tcon tmod tl0 tl1 th0 th1 ckcon 8f 80 p0 sp dpl dph dp l1 dph1 dps pcon 87 note: the sfrs in the column with dark borders are bit - addressable. table 8 - 1 : special function register location table
preliminary n 79 e352/n79e352r data sheet - 18 - symbol definition address msb bit address, sym bol lsb reset ip1 interrupt priority 1 f8h pcap pbo - pwdi - - pkb pi2 00x0 xx00b ip1h interrupt high priority 1 f7h pcaph pboh - pwdih - - pkbh pi2h 00x0 xx00b b b register f0h b.7 b.6 b.5 b.4 b.3 b. 2 b.1 b.0 0000 0000b p5m2 port 5 output mode 2 eeh - - - - - - p5m2.1 p5m2.0 config0.pmod e=1; xxxx xx00b config0.pmod e=0; xxxx xx11b p5m1 port 5 output mode 1 edh - - - - - enclk p5m1.1 p5m1.0 config0.pmod e=1; xxxx x000b config0.pmod e=0; xxxx x011b port s port shmitt register ech - - p5s - p3s p2s p1s p0s xx0x 0000b kbl keyboard level register e9h kbl.7 kbl.6 kbl.5 kbl.4 kbl.3 kbl.2 kbl.1 kbl.0 0000 0000b eie interrupt enable 1 e8h ecptf ebo - ewdi - - ekb ei2 00x0 xx00b cch0 input capture 0 high e5h c ch0.7 cch0.6 cch0.5 cch0.4 cch0.3 cch0.2 cch0.1 cch0.0 0000 0000b ccl0 input capture 0 low e4h ccl0.7 ccl0.6 ccl0.5 ccl0.4 ccl0.3 ccl0.2 ccl0.1 ccl0.0 0000 0000b acc accumulator e0h acc.7 acc.6 acc.5 acc.4 acc.3 acc.2 acc.1 acc.0 0000 0000b pwmcon1 pwm control register 1 dch pwmrun - - clrpwm - - - - 0xx0 xxxxb pwm1l pwm 1 low bits register dbh pwm1.7 pwm1.6 pwm1.5 pwm1.4 pwm1.3 pwm1.2 pwm1.1 pwm1.0 0000 0000b pwm0l pwm 0 low bits register dah pwm0.7 pwm0.6 pwm0.5 pwm0.4 pwm0.3 pwm0.2 pwm0.1 pwm0.0 0000 0000b wdcon watch - dog control d8h wdrun por - - wdif wtrf ewrst wdclr por: x1xx 0000b external reset: xxxx 0xx0b watchdog reset: xxxx 01x0b pwmcon3 pwm control register 3 d7h - - pwm1oe pwm0oe pclk.1 pclk.0 fp1 fp0 xx00 0000b psw program status word d 0h cy ac f0 rs1 rs0 ov f1 p 0000 0000b nvmdata nvm data cfh nvmdata.7 nvmdata.6 nvmdata.5 nvmdata.4 nvmdata. 3 nvmdata. 2 nvmdata. 1 nvmdata. 0 0000 0000b nvmcon nvm control ceh eer ewr ennvm - - - - - 000x xxxxb th2 timer 2 msb cdh th2.7 th2.6 th2.5 t h2.4 th2.3 th2.2 th2.1 th2.0 0000 0000b tl2 timer 2 lsb cch tl2.7 tl2.6 tl2.5 tl2.4 tl2.3 tl2.2 tl2.1 tl2.0 0000 0000b rcap2h timer 2 reload msb cbh rcap2h.7 rcap2h.6 rcap2h.5 rcap2h.4 rcap2h.3 rcap2h.2 rcap2h.1 rcap2h.0 0000 0000b rcap2l timer 2 reload lsb cah rcap2l.7 rcap2l.6 rcap2l.5 rcap2l.4 rcap2l.3 rcap2l.2 rcap2l.1 rcap2l.0 0000 0000b t2mod timer 2 mode c9h - - - icen0 t2cr 1 t2oe dcen xxx0 0100b t2con timer 2 control c8h tf2 exf2 rclk tclk exen2 tr2 c/t2 cp/rl 0000 0000b ta timed access prote ction c7h ta.7 ta.6 ta.5 ta.4 ta.3 ta.2 ta.1 ta.0 0000 0000b nvmaddr nvm low byte address c6h nvmaddr.7 nvmaddr.6 nvmaddr.5 nvmaddr.4 nvmaddr. 3 nvmaddr. 2 nvmaddr. 1 nvmaddr. 0 0000 0000b status status register c5h - - - - - - spta0 spra0 xxxx xx00b pmr power management register c4h cd1 cd0 swb - - ale - off - - 010x xxxxb rommap rommap register c2h ws 1 - - - 1 1 0 01xxx110b i2addr i2c address1 c1h addr.7 addr.6 addr.5 addr.4 addr.3 addr.2 addr.1 gc xxxxxxx0b
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 19 - revision a0 6 symbol definition address msb bit address, sym bol lsb reset i2con i2c control register c0h - ens i sta sto si aa - - x00000xxb i2timer i2c timer counter register bfh - - - - - enti div4 tif xxxx x000b i2clk i2c clock rate beh i2clk.7 i2clk.6 i2clk.5 i2clk.4 i2clk.3 i2clk.2 i2clk.1 i2clk.0 0000 0000b i2status i2c status bdh i2status.7 i2status.6 i2 status.5 i2status.4 i2status. 3 i2status. 2 i2status. 1 i2status. 0 1111 1000b i2dat i2c data bch i2dat.7 i2dat.6 i2dat.5 i2dat.4 i2dat.3 i2dat.2 i2dat.1 i2dat.0 xxxxxxxxb saden slave address mask b9h saden.7 saden.6 saden.5 saden.4 saden.3 saden.2 saden.1 s aden.0 00000000b ip0 interrupt priority b8h - - pt2 ps pt1 px1 pt0 px0 xx00 0000b ip0h interrupt high priority b7h - - pt2h psh pt1h px1h pt0h px0h xx00 0000b p2m2 port 2 output mode 2 b6h p2m2.7 p2m2.6 p2m2.5 p2m2.4 p2m2.3 p2m2.2 p2m2.1 p2m2.0 config0. pmod e=1; 0000 0000b config0.pmod e=0; 1111 1111b p2m1 port 2 output mode 1 b5h p2m1.7 p2m1.6 p2m1.5 p2m1.4 p2m1.3 p2m1.2 p2m1.1 p2m1.0 config0.pmod e=1; 0000 0000b config0.pmod e=0; 1111 1111b p1m2 port 1 output mode 2 b4h p1m2.7 p1m2.6 p1m2.5 p1m2.4 p1m2.3 p1m2.2 p1m2.1 p1m2.0 config0.pmod e=1; 0000 0000b config0.pmod e=0; 1111 1111b p1m1 port 1 output mode 1 b3h p1m1.7 p1m1.6 p1m1.5 p1m1.4 p1m1.3 p1m1.2 p1m1.1 p1m1.0 config0.pmod e=1; 0000 0000b config0.pmod e=0; 1111 1111b p0m2 port 0 output mode 2 b2h p0m2 .7 p0m2.6 p0m2.5 p0m2.4 p0m2.3 p0m2.2 p0m2.1 p0m2.0 1111 1111b p0m1 port 0 output mode 1 b1h p0m1.7 p0m1.6 p0m1.5 p0m1.4 p0m1.3 p0m1.2 p0m1.1 p0m1.0 1111 1111b p3 port3 b0h p3.7 p3.6 p 3.5 p3.4 p3 .3 p3 .2 p 3 .1 p3 .0 1111 1111b /rd /wr t1 t0 /int1 /int 0 txd rxd saddr slave address a9h saddr.7 saddr.6 saddr.5 saddr.4 saddr.3 saddr.2 saddr.1 saddr.0 0000 0000b ie interrupt enable a8h ea - et2 es et1 ex1 et0 ex0 0x00 0000b p4 port4 a5h - - - - p4.3 p4.2 p4.1 p4.0 xxxx 1111b capcon1 capture control 1 a4h 0 t0cc - - enf0 - - cptf0 00xx 0xx0b capcon0 capture control 0 a3h - - - - cct0.1 cct0.0 - - xxxx 00xxb auxr1 aux function register 1 a2h kbf bod boi lpbov srst bov1 bov0 bos 0000 0000b kbi keyboard interrupt a1h kbi.7 kbi.6 kbi.5 kbi.4 kbi.3 kbi.2 kbi.1 kbi.0 0000 0000b p2 port 2 a0h p2.7 p2.6 p 2.5 p2.4 p2 .3 p2 .2 p 2 .1 p2 .0 1111 1111b a15 a14 a13 a12 a11 a10 a9 a8 p3m2 port 3 output mode 2 9fh p3m2.7 p3m2.6 p3m2.5 p3m2.4 p3m2.3 p3m2.2 p3m2.1 p3m2.0 config0.pmod e=1; 0000 0000b config0.pmod e= 0; 1111 1111b
preliminary n 79 e352/n79e352r data sheet - 20 - symbol definition address msb bit address, sym bol lsb reset p3m1 port 3 output mode 1 9eh p3m1.7 p3m1.6 p3m1.5 p3m1.4 p3m1.3 p3m1.2 p3m1.1 p3m1.0 config0.pmod e=1; 0000 0000b config0.pmod e=0; 1111 1111b sbuf serial buffer 99h sbuf.7 sbuf.6 sbuf.5 sbuf.4 sbuf.3 sbuf.2 sbuf.1 sbuf.0 xxxx xxxxb scon se rial control 98h sm0/fe sm1 sm2 ren tb8 rb8 ti ri 0000 0000b p5 port5 94h - - - - - - p5.1 p5.0 xxxx xx11b - - - - - - xtal1 xtal2 - - - - - - - clkout p1 port 1 90h p1.7 p1.6 p 1.5 p1.4 p1 .3 p1 .2 p 1 .1 p1 .0 1111 1111b - - pwm1 pwm0 scl sd a t2ex t2 ckcon clock control 8eh wd1 wd0 t2m t1m t0m md2 md1 md0 0000 0001b th1 timer high 1 8dh th1.7 th1.6 th1.5 th1.4 th1.3 th1.2 th1.1 th1.0 0000 0000b th0 timer high 0 8ch th0.7 th0.6 th0.5 th0.4 th0.3 th0.2 th0.1 th0.0 0000 0000b tl1 timer low 1 8bh tl1.7 tl1.6 tl1.5 tl1.4 tl1.3 tl1.2 tl1.1 tl1.0 0000 0000b tl0 timer low 0 8ah tl0.7 tl0.6 tl0.5 tl0.4 tl0.3 tl0.2 tl0.1 tl0.0 0000 0000b tmod timer mode 89h gate c/t m1 m0 gate c/t m1 m0 0000 0000b tcon timer control 88h tf1 tr1 tf0 tr0 ie1 it1 i e0 it0 0000 0000b pcon power control 87h sm0d smod0 bof - gf1 gf0 pd idl 001x 0000b dps data pointer select 86h - - - - - - - dps.0 xxxx xxx0b dph1 data pointer high 1 85h dph1.7 dph1.6 dph1.5 dph1.4 dph1.3 dph1.2 dph1.1 dph1.0 0000 0000b dpl1 data poi nter low 1 84h dpl1.7 dpl1.6 dpl1.5 dpl1.4 dpl1.3 dpl1.2 dpl1.1 dpl1.0 0000 0000b dph data pointer high 83h dph.7 dph.6 dph.5 dph.4 dph.3 dph.2 dph.1 dph.0 0000 0000b dpl data pointer low 82h dpl.7 dpl.6 dpl.5 dpl.4 dpl.3 dpl.2 dpl.1 dpl.0 0000 0000b sp stack pointer 81h sp.7 sp.6 sp.5 sp.4 sp.3 sp.2 sp.1 sp.0 0000 0111b p0 port 0 80h p0.7 p0.6 p 0.5 p0.4 p0 .3 p0 .2 p 0 .1 p0 .0 1111 1111b ad7 ad 6 ad 5 ad 4 ad 3 ad 2 ad 1 ad 0 kb7 kb6 kb5 kb4 kb3 kb2 kb1 kb0
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 21 - revision a0 6 8.2 sfr detail bit d escription s port 0 bit: 7 6 5 4 3 2 1 0 p0.7 p0.6 p0.5 p0.4 p0.3 p0.2 p0.1 p0.0 mnemonic: p0 address: 80h port 0 is an open - drain bi - dire ctional i/o port. this port provides a multipl exed low order address/data bus during accesses to external memory. the ports also support alte rnate input funct ion for keyboard pins (kb0 - 7). bit name function 7 p0 .7 ad7 or kb7 or i/o p in by alternative. 6 p0 .6 ad6 or kb6 or i/o p in by alternative. 5 p0.5 ad5 or kb5 or i/o p in by alternative. 4 p0.4 ad4 or kb4 or i/o p in by alternative. 3 p0 . 3 ad3 or kb3 or i/o p in by alternative. 2 p0 .2 ad2 or kb2 or i/o p in by alternative. 1 p0 .1 ad1 or kb1 or i/o p in by alternative. 0 p0 .0 ad0 or kb0 or i/o pin by alternative. note: the initial value of the port is set by config0.prhi bit. the default s etting for config0.prhi =1 which the alternative function output is turned on upon reset. if config0.prhi is set to 0, the user has to write a 1 to port sfr to turn on the alternative function output. stack pointer bit: 7 6 5 4 3 2 1 0 sp.7 sp.6 sp.5 sp. 4 sp.3 sp.2 sp.1 sp.0 mnemonic: sp address: 81h bit name function 7 - 0 sp.[7:0] the stack pointer stores the scratch - pad ram address where the stack begins. in other words it always points to the top of the stack. data pointer low bit: 7 6 5 4 3 2 1 0 dpl.7 dpl.6 dpl.5 dpl.4 dpl.3 dpl.2 dpl.1 dpl.0 mnemonic: dpl a ddress: 82h bit name function 7 - 0 dpl.[7:0] this is the low byte of the standard 8052 16 - bit data pointer. data pointer high bit: 7 6 5 4 3 2 1 0
preliminary n 79 e352/n79e352r data sheet - 22 - dph.7 dph.6 dph.5 dph.4 dph.3 dph.2 dph.1 dph.0 mnemonic: dph a ddress: 83h bit name function 7 - 0 dph.[7:0] this is the high byte of the standard 8052 16 - bit data pointer. this is the high byte of the dptr 16 - bit data pointer. data pointer low 1 bit: 7 6 5 4 3 2 1 0 dpl1.7 dpl1.6 dpl1.5 dpl1 .4 dpl1.3 dpl1.2 dpl1.1 dpl1.0 mnemonic: dpl 1 a ddress: 84 h bit name function 7 - 0 dpl 1 .[7:0] this is the low byte of the new additional 16 - bit data pointer that has been added to the n79e352(r) . the user can switch between dpl, dph and dpl1, dph1 simply b y setting register dps = 1. the instructions that use dptr will now access dpl1 and dph1 in place of dpl and dph. if they are not required they can be used as conventional register locations by the user. data pointer high 1 bit: 7 6 5 4 3 2 1 0 dph1.7 d ph1.6 dph1.5 dph1.4 dph1.3 dph1.2 dph1.1 dph1.0 mnemonic: dph 1 a ddress: 85 h bit name function 7 - 0 dph 1 .[7:0] this is the high byte of the new additional 16 - bit data pointer that has been added to the n79e352(r) . the user can switch between dpl, dph and d pl1, dph1 simply by setting register dps = 1. the instructions that use dptr will now access dpl1 and dph1 in place of dpl and dph. if they are not required they can be used as conventional register locations by the user. data pointer select bit: 7 6 5 4 3 2 1 0 - - - - - - - dps.0 mnemonic: dps a ddress: 86 h bit name function 7 - 1 - reserved. 0 dps this bit is used to select either the dpl,dph pair or the dpl1,dph1 pair as the active data pointer. when set to 1, dpl1, dph1 will be selected, otherwise d pl, dph will be selected. power control bit: 7 6 5 4 3 2 1 0
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 23 - revision a0 6 sm o d smod0 bof - gf1 gf0 pd idl mnemonic: pcon address: 87h bit name function 7 smod 1: this bit doubles the serial port baud rate in mode 1, 2, and 3. 6 smod0 0: framing error detection di sable. scon.7 (sm0/fe) bit is used as sm0 (standard 8052 function). 1: framing error detection enable. scon.7 (sm0/fe) bit is used to reflect as frame error (fe) status flag. 5 bof 0: cleared by software. 1: set automatically when a brownout reset or inte rrupt has occurred. also set at power on. 4 - reserved. 3 gf1 g eneral purpose user flags. 2 gf0 g eneral purpose user flags. 1 pd 1: t he cpu goes into the power down mode. in this mode , all the clocks are stopped and program execution is frozen. 0 idl 1: the cpu goes into the idle mode. in this mode , the clocks cpu clock stopped, so program execution is frozen. but the clock to the serial, timer and interrupt blocks is not stopped, and these blocks continue operating. timer control bit: 7 6 5 4 3 2 1 0 tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 mnemonic: tcon address: 88h bit name function 7 tf1 timer 1 o verflow f lag . this bit is set when timer 1 overflows. it is cleared automatically when the program does a timer 1 interrupt service routine. software can als o set or clear this bit. 6 tr1 timer 1 r un c ontrol . this bit is set or cleared by software to turn timer/counter on or off. 5 tf0 timer 0 o verflow f lag . this bit is set when timer 0 overflows. it is cleared automatically when the program does a timer 0 interrupt service routine. software can also set or clear this bit. 4 tr0 timer 0 r un c ontrol . this bit is set or cleared by software to turn timer/counter on or off. 3 ie1 interrupt 1 e dge d etect flag : set by hardware when an edge/level is detected on int1 . this bit is cleared by hardware when the service routine is vectored to only if the interrupt was edge triggered. otherwise it follows the inverse of the pin. 2 it1 interrupt 1 t ype c ontrol . set/cleared by software to specify falling edge/ low level tri ggered external inputs. 1 ie0 interrupt 0 e dge d etect flag. set by hardware when an edge/level is detected on
preliminary n 79 e352/n79e352r data sheet - 24 - int 0 . this bit is cleared by hardware when the service routine is vectored to only if the interrupt was edge triggered. otherwise it follows the inv erse of the pin. 0 it0 interrupt 0 type c ontrol: set/cleared by software to specify falling edge/ low level triggered external inputs. timer mode control bit: 7 6 5 4 3 2 1 0 gate t c / m1 m0 gate t c / m1 m0 timer 1 timer0 mnemonic: tmod address: 89h bit name function 7 gate gating control: when this bit is set, timer/counter 1 is enabled only while the int1 pin is high and the tr 1 control bit is set. when clear ed, the int1 pin has no effect, and timer 1 is enabled whenever tr1 control bit is set. 6 t c/ timer or counter select: when clear, t imer 1 is incremented by the internal clock. when set, the timer counts falling edges on the t 1 pin. 5 m1 timer 1 m ode s elect bit 1. see table below. 4 m0 timer 1 m ode s elect bit 0. see table below. 3 gate gating control: when this bit is set, timer/counter 0 is enabled only while the int0 pin is high and the tr 0 control bit is set. when clear ed, the int0 pin has no effect, and timer 0 is enabled whenever tr0 control bit is set. 2 t c/ timer or counter select: when clear, t imer 0 is incremented by the internal clock. when set, the timer counts falling edges on the t 0 pin. 1 m1 timer 0 m ode s elect bit 1. see table below. 0 m0 timer 0 m ode s elect bit 0. see table below. m1, m0: mode select bits: m1 m0 mode 0 0 mode 0: 8 - bit timer/counter tlx serves as 5 - bit pre - scale. 0 1 mode 1: 16- bit timer/counter , no pre - scale. 1 0 mode 2: 8 - bit timer/counter with auto - reload from thx. 1 1 mode 3: (timer 0) tl0 is an 8 - bit timer/counter controlled by the standard timer0 control bits. th0 is a n 8 - bit timer only controlled by timer1 control bits. (timer 1) timer/ c ounter 1 is stopped. t imer 0 lsb b it: 7 6 5 4 3 2 1 0 tl0.7 tl0.6 tl0.5 tl0.4 tl0.3 tl0.2 tl0.1 tl0.0 mnemonic: tl0 address: 8a h
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 25 - revision a0 6 bit name function 7 - 0 tl0.[7:0] timer 0 lsb. timer 1 lsb bit: 7 6 5 4 3 2 1 0 tl1.7 tl1.6 tl1.5 tl1.4 tl1.3 tl1.2 tl1.1 tl1.0 mnemonic: tl1 address: 8b h bit name function 7 - 0 tl1.[7:0] timer 1 lsb. timer 0 msb bit: 7 6 5 4 3 2 1 0 th0.7 th0.6 th0.5 th0.4 th0.3 th0.2 th0.1 th0.0 mnemonic: th0 address: 8ch bit name function 7 - 0 th0.[7:0] timer 0 msb. timer 1 msb bit: 7 6 5 4 3 2 1 0 th1.7 th1.6 th1 .5 th1.4 th1.3 th1.2 th1.1 th1.0 mnemonic: th1 address: 8dh bit name function 7 - 0 th1.[7:0] timer 1 msb. clock control bit: 7 6 5 4 3 2 1 0 wd1 wd0 t2m t1m t0m md2 md1 md0 mnemonic: ckcon address: 8eh bit name function 7 - 5 wd1~0 watchdog timer mode select bits: these bits determine the time - out period for the watchdog timer. in all four time - out options the reset time - out is 512 clocks more than the interrupt time - out period. wd1 wd0 interrupt time - out reset time - out 0 0 2 6 2 6 + 512 0 1 2 9 2 9 + 51 2 1 0 2 13 2 13 + 512 1 1 2 15 2 15 + 512
preliminary n 79 e352/n79e352r data sheet - 26 - bit name function 5 t 2 m timer 2 clock select: 0: timer 2 uses a divide by 12 clocks. 1: timer 2 uses a divide by 4 clocks. 4 t1m timer 1 clock select: 0: timer 1 uses a divide by 12 clocks. 1: timer 1 uses a divide by 4 clocks. 3 t0m timer 0 clock select: 0: timer 0 uses a divide by 12 clocks. 1: timer 0 uses a divide by 4 clocks. 2~ 0 md2~0 stretch movx select bit s: these three bits are used to select the stretch value for the movx instruction. using a variable movx length enab les the user to access slower external memory devices or peripherals without the need for external circuits. the rd or wr strobe will be stretched by the selected interval. when accessing the on - chip sram, the movx instr uction is always in 2 machine cycles regardless of the stretch setting. by default, the stretch has value of 1. if the user needs faster accessing, then a stretch value of 0 should be selected. md2 md1 md0 stretch value movx duration 0 0 0 0 2 machine c ycles 0 0 1 1 3 machine cycles (default) 0 1 0 2 4 machine cycles 0 1 1 3 5 machine cycles 1 0 0 4 6 machine cycles 1 0 1 5 7 machine cycles 1 1 0 6 8 machine cycles 1 1 1 7 9 machine cycles port 1 bit: 7 6 5 4 3 2 1 0 p1.7 p1.6 p1. 5 p1.4 p1.3 p1.2 p1.1 p1.0 mnemonic: p1 address: 90h p1.7 - 0: general purpose input/output port. most instructions will read the port pins in case of a port read access, however in case of read - modify - write instructions, the port latch is read. these alte rnate functions are described below: bit name function 7 p1.7 dedicated i/o p in . 6 p1.6 dedicated i/o p in . 5 p1.5 pwm1 or i/o p in by alternative. 4 p1.4 pwm0 or i/o p in by alternative.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 27 - revision a0 6 bit name function 3 p1.3 scl or i/o p in by alternative. 2 p1.2 sda or i/o p in by al ternative. 1 p1.1 t2ex or i/o p in by alternative. 0 p1.0 t2 or i/o p in by alternative. port 5 bit: 7 6 5 4 3 2 1 0 - - - - - - p5.1/ xtal1 p5.0/ xtal2/ clkout mnemonic: p 5 address: 94 h bit name function 7~2 - reserved. 1 p5.1 xtal1 clock input or i/o p in by alternative. 0 p5.0 xtal2 or clkout pin or i/o p in by alternative. serial port control bit: 7 6 5 4 3 2 1 0 sm0/fe sm1 sm2 ren tb8 rb8 ti ri mnemonic: scon address: 98h bit name function 7 sm0/fe serial port m ode select bit 0 or framing er ror flag: the smod0 bit in pcon sfr determines whether this bit acts as sm0 or as fe. the operation of sm0 is described below. when used as fe, this bit will be set to indicate an invalid stop bit. this bit must be manually cleared in software to clear the fe condition. 6 sm1 serial p ort mode select bit 1. see table below. 5 sm2 multiple processors communication. setting this bit to 1 enables the multiprocessor communication feature in mode 2 and 3. in mode 2 or 3, if sm2 is set to 1, then ri will not be activated if the received 9th data bit (rb8) is 0. in mode 1, if sm2 = 1, then ri will not be activated if a valid stop bit was not received. in mode 0, the sm2 bit controls the serial port clock. if set to 0, then the serial port runs at a divide by 12 cl ock of the oscillator. this gives compatibility with the standard 8052. when set to 1, the serial clock become divide by 4 of the oscillator clock. this results in faster synchronous serial communication. 4 ren receive enable: 0: disable serial reception. 1 : enable serial reception. 3 tb8 this is the 9th bit to be transmitted in modes 2 and 3. this bit is set and cleared by software as desired. 2 rb8 in modes 2 and 3 this is the received 9th data bit. in mode 1, if sm2 = 0, rb8 is
preliminary n 79 e352/n79e352r data sheet - 28 - bit name function the stop bit that was r eceived. in mode 0 it has no function. 1 ti transmit interrupt flag: this flag is set by hardware at the end of the 8th bit time in mode 0, or at the beginning of the stop bit in all other modes during serial transmission. this bit must be cleared by soft ware. 0 ri receive interrupt flag: this flag is set by hardware at the end of the 8th bit time in mode 0, or halfway through the stop bits time in the other modes during serial reception. however the restrictions of sm2 apply to this bit. this bit can be cleared only by software. s m1, s m0: mode select bits: mode s m1 s m0 description length baud rate 0 0 0 synchronous 8 f cpu divided by 4 or 12 1 0 1 asynchronous 10 variable 2 1 0 asynchronous 11 f cpu divided by 32 or 64 3 1 1 asynchronous 11 variable s erial data buffer bit: 7 6 5 4 3 2 1 0 sbuf.7 sbuf.6 sbuf.5 sbuf.4 sbuf.3 sbuf.2 sbuf.1 sbuf.0 mnemonic: sbuf address: 99h bit name function 7 - 0 sbuf.[7:0] serial data on the serial port is read from or written to this location. it actually consists of two separate internal 8 - bit registers. one is the receive resister, and the other is the transmit buffer. any read access gets data from the receive data buffer, while write access is to the transmit data buffer. port 3 output mode 1 bit: 7 6 5 4 3 2 1 0 p3m1.7 p3m1.6 p3m1.5 p3m1.4 p3m1.3 p3m1.2 p3m1.1 p3m1.0 mnemonic: p3m1 address: 9eh bit name function 7 - 0 p3m1.7 - 0 to control the output configuration of p3 [7:0 ]. port 3 output mode 2 bit: 7 6 5 4 3 2 1 0 p3m2.7 p3m2.6 p3m2.5 p3m2.4 p3m2.3 p3m2.2 p3m2.1 p3m2.0 mnemonic: p3m2 address: 9fh bit name function 7 - 0 p3m2.7 - 0 see as below table.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 29 - revision a0 6 port output configuration settings: p x m1.y p x m2.y port input/ output mode 0 0 quasi - bidirectional 0 1 push - pull 1 0 input only (high impedance) ports.pxs=0, t tl input ports.pxs=1, schmitt input 1 1 open drain note: 1. x = 0 - 3, 5. y = 0 - 7. 2. config0.pmode bit will determine the port1~3 and port 5 are quasi or open drain upon reset. see detail pmode descriptions. port 2 bit: 7 6 5 4 3 2 1 0 p2.7 p2.6 p2.5 p2.4 p 2.3 p2.2 p2.1 p2.0 mnemonic: p2 address: a0h p2.7 - 0: port 2 is a bi - directional i/o port with internal pull - ups. this port also provides the upper address bits for accesses to external memory. bit name function 7 p2 .7 a15 or i/o p in by alternative. 6 p 2 .6 a14 or i/o p in by alternative. 5 p2.5 a13 or i/o p in by alternative. 4 p2.4 a12 or i/o p in by alternative. 3 p2 .3 a11 or i/o p in by alternative. 2 p2 .2 a10 o r i/o p in by alternative. 1 p2 .1 a9 or i/o p in by alternative. 0 p2 .0 a8 or i/o pin by al ternative. keyboard interrupt bit: 7 6 5 4 3 2 1 0 kbi.7 kbi.6 kbi.5 kbi.4 kbi.3 kbi.2 kbi.1 kbi.0 mnemonic: kbi address: a1h bit name function 7 kbi.7 1: enable p0.7 as a cause of a keyboard interrupt. 6 kbi.6 1: enable p0.6 as a cause of a keyboar d interrupt. 5 kbi.5 1: enable p0.5 as a cause of a keyboard interrupt. 4 kbi.4 1: enable p0.4 as a cause of a keyboard interrupt.
preliminary n 79 e352/n79e352r data sheet - 30 - 3 kbi.3 1: enable p0.3 as a cause of a keyboard interrupt. 2 kbi.2 1: enable p0.2 as a cause of a keyboard interrupt. 1 kbi.1 1: enable p0.1 as a cause of a keyboard interrupt. 0 kbi.0 1: enable p0.0 as a cause of a keyboard interrupt. aux function register 1 bit: 7 6 5 4 3 2 1 0 kbf bod boi lpbov srst bov1 bov0 bos mnemonic: auxr1 address: a2h bit name function 7 kbf keyboard interrupt flag: 1: when any pin of port 0 that is enabled for the keyb oard interrupt function triggers (trigger level is depending on sfr kbl configuration) . must be cleared by software. 6 bod brown out disable: 0: enable brownout detect functio n. 1: disable brownout detect function and save power. bod is initialized at all reset s with the inverse value of bit cbod in config 0.3 bit . user is able to re - configure this bit after reset. 5 boi brown out interrupt: 0: disable brownout detect interrup t function. 1: this prevents brownout detection from causing a chip reset and allows the brownout detect function to be used as an interrupt. 4 lpbov low power brown out detect control: 0: when bod is enable, the brown out detect is always turned on by no rmal run or p ower down mode. 1: when bod is enable, the 1/16 time will be turned on brown out detect circuit by power down mode. when uc is entry power d o wn mode, the bod will enable internal rc osc ( 2 0k h z ) . 3 srst software reset: 1: reset the chip as if a hardware reset occurred. srst require timed access procedure to write. the remaining bits have unrestricted write accesses. please refer ta register description.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 31 - revision a0 6 2~ 1 bov.1~0 brownout voltage selection bits, see below table. bov.1 bov.0 brownout voltage 0 x brownout voltage is 2. 6 v 1 0 brownout voltage is 3.8v 1 1 brownout voltage is 4.5v these bits are initialized at all resets with the inverse values of bits cbov.1 - 0 in config1.3 - 2 bits. user is able to re - configure these bits after reset. 0 bos b rownout status bit(read only) 0: v dd is above v bor+ 1: v dd is below v bor- capture control 0 register bit: 7 6 5 4 3 2 1 0 - - - - cct 0. 1 cc t0 . 0 - - mnemonic: c apcon 0 address: a3 h bit name function 7 - 4 - reserved. 3 - 2 cct 0 [1:0] capture 0 edge select: 00 : rising edge trigger. 01 : falling edge trigger. 10 : either rising or falling edge trigger. 11 : reserved 1 - 0 - reserved. capture control 1 register bit: 7 6 5 4 3 2 1 0 0 t0cc - - enf0 - - cptf0 mnemonic: capcon1 address: a4 h bit name function 7 - must be 0. 6 t0cc timer 0 clear counter bit. 0: timer 0 is not clear when input capture/cap sensor trigger. 1: timer 0 will be cleared when input capture/cap sensor trigger. 5 - 4 - reserved. 3 e nf0 enable filter for capture input 0.
preliminary n 79 e352/n79e352r data sheet - 32 - 2 - 1 - reserved. 0 cptf0 external input capture 0 interrupt flag. it can be cleared by software. port 4 bit: 7 6 5 4 3 2 1 0 - - - - p4.3 p4.2 p4.1 p4.0 mnemonic: p4 address: a5 h bit name function 7 ~4 - reserved. 3~ 0 p4.3~0 port 4 is a bi - directional i/o port with i nternal pull - ups. port 4 can not use bit - addressable instruction (setb or clr). interrupt enable bit: 7 6 5 4 3 2 1 0 ea - et2 es et1 ex1 et0 ex0 mnemonic: ie address: a8h bit name function 7 ea global enable. enable/ d isable all interrupts . 6 - reser ved. 5 et2 enable timer 2 interrupt. 4 es enable serial port 0 interrupt. 3 et1 enable timer 1 interrupt. 2 ex1 enable external interrupt 1. 1 et0 enable timer 0 interrupt. 0 ex0 enable external interrupt 0. slave address bit: 7 6 5 4 3 2 1 0 sadd r.7 saddr.6 saddr.5 saddr.4 saddr.3 saddr.2 saddr.1 saddr.0 mnemonic: saddr address: a9h bit name function 7~0 saddr the saddr should be programmed to the given or broadcast address for serial port 0 to which the slave processor is designated. port 3 b it: 7 6 5 4 3 2 1 0 p3.7 p3.6 p3.5 p3.4 p3.3 p3.2 p3.1 p3.0 mnemonic: p3 address: b0h
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 33 - revision a0 6 p3.7 - 0: general purpose input/output port. most instructions will read the port pins in case of a port read access, however in case of read - modify - write instructions, the port latch is read. these alternate functions are described below: bit name function 7 p3.7 /rd or i/o p in by alternative. 6 p3.6 /wr or i/o p in by alternative. 5 p3.5 t1 or i/o p in by alternative. 4 p3.4 t0 or i/o p in by alternative. 3 p3.3 /int1 or i/o p in by alternative. 2 p3.2 /int0 or i/o p in by alternative. 1 p3.1 txd or i/o p in by alternative. 0 p3.0 rxd or i/o pin by alternative. port 0 output mode 1 bit: 7 6 5 4 3 2 1 0 p0m1.7 p0m1.6 p0m1.5 p0m1.4 p0m1.3 p0m1.2 p0m1.1 p0m1.0 mnemoni c: p0m1 address: b1h bit name function 7 - 0 p0m1 to control the output configuration of p0 bits [7:0] port 0 output mode 2 bit: 7 6 5 4 3 2 1 0 p0m2.7 p0m2.6 p0m2.5 p0m2.4 p0m2.3 p0m2.2 p0m2.1 p0m2.0 mnemonic: p0m2 address: b2h bit name function 7 - 0 p0m2 to control the output configuration of p0 bits [7:0] port 1 output mode 1 bit: 7 6 5 4 3 2 1 0 p1m1.7 p1m1.6 p1m1.5 p1m1.4 p1m1. 3 p1m1. 2 p1m1.1 p1m1.0 mnemonic: p1m1 address: b3h bit name function 7 - 0 p1m1 to control the ou tput configuration o f p1 bits [7 :0]. port 1 output mode 2 bit: 7 6 5 4 3 2 1 0 p1m2.7 p1m2.6 p1m2.5 p1m2.4 p1m2.3 p1m2.2 p1m2.1 p1m2.0 mnemonic: p1m2 address: b4h
preliminary n 79 e352/n79e352r data sheet - 34 - bit name function 7 - 0 p1m2 to control the ou tput configuration of p1 bits [7 :0]. port 2 output mode 1 bit: 7 6 5 4 3 2 1 0 p2m1.7 p2m1.6 p2m1.5 p2m1.4 p2m1.3 p2m1.2 p2m1.1 p2m1.0 mnemonic: p2m1 address: b5h bit name function 7 - 0 p2m1 to control the output configuration of p2 bits [7:0] port 2 output mode 2 bit: 7 6 5 4 3 2 1 0 p2m2.7 p2m2.6 p2m2.5 p2m2.4 p2m2.3 p2m2.2 p2m2.1 p2m2.0 mnemonic: p2m2 address: b6h bit name function 7 - 0 p2m2 to control the output configuration of p2 bits [7:0] interrupt high priority bit: 7 6 5 4 3 2 1 0 - - p t2h ps h pt1 h px1 h pt0 h px0 h mnemonic: ip0 h address: b 7 h bit nam e function 7 ~6 - reserved. 5 pt2h 1: to set interrupt high priority of timer 2 is highest priority level. 4 psh 1: to set interrup t high priority of serial port is highe st priority level. 3 pt1h 1: ro set interrupt high priority of timer 1 is highest p riority level. 2 px1h 1: to set interrupt high priority of external interrupt 1 is highe st priority level. 1 pt0h 1: to set interrupt high priority of timer 0 is highe st priority level. 0 px0h 1: to set interrupt high priority of external interrupt 0 is highe st priority level. interrupt priority 0 bit: 7 6 5 4 3 2 1 0 - - pt2 ps pt1 px1 pt0 px0 mnemonic: ip0 address: b8h bit name function 7 ~6 - reserved. 5 pt2 1: to set interrupt priority of timer 2 is higher priority level. 4 ps 1: to set interru pt priority of seria l port is higher priority level.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 35 - revision a0 6 3 pt1 1: to set interrupt priority of timer 1 is higher priority level. 2 px1 1: to set interrupt priority of external interrupt 1 is higher priority level. 1 pt0 1: to set interrupt priority of timer 0 is higher priority level. 0 px0 1: to set interrupt priority of external interrupt 0 is higher priority level. slave address mask enable bit: 7 6 5 4 3 2 1 0 saden.7 saden.6 saden.5 saden.4 saden.3 saden.2 saden.1 saden.0 mnemonic: saden ad dress: b9h bit name function 7~0 saden this register enables the automatic address recognition feature of the serial port 0. when a bit in the saden is set to 1, the same bit location in saddr will be compared with the incoming serial data. when saden is 0, then the bit becomes a "don't care" in the comparison. this register enables the automatic address recognition feature of the serial port 0. when all the bits of saden are 0, interrupt will occur for any incoming address. i2c data register bit: 7 6 5 4 3 2 1 0 i2dat.7 i2dat.6 i2dat.5 i2dat.4 i2dat.3 i2dat.2 i2dat.1 i2dat.0 mnemonic: i2dat address: b c h bit name function 7 - 0 i2dat.[7:0] the data register of i2c. i2c status register bit: 7 6 5 4 3 2 1 0 i2status.7 i2status.6 i2status.5 i2status.4 i 2status.3 - - - mnemonic: i2status address: b dh bit name function 7 - 0 i2status.[7:0] the status register of i2c: the three least significant bits are always 0. the five most significant bits contain the status code. there are 23 possible status codes. wh en i2status contains f8h, no serial interrupt is requested. all other i2status values correspond to defined i2c states. when each of these states is entered, a status interrupt is requested (si = 1). a valid status code is present in i2status one machine c ycle after si is set by hardware and is still present one machine cycle after si has been reset by software. in addition, states 00h stands for a bus error. a bus error occurs when a start or stop condition is present at an illegal position in the formatio n frame. example of illegal position are during the serial transfer of an address byte, a data byte or an acknowledge bit. i2c baud rate control register bit: 7 6 5 4 3 2 1 0
preliminary n 79 e352/n79e352r data sheet - 36 - i2clk.7 i2clk.6 i2clk.5 i2clk.4 i2clk.3 i2clk.2 i2clk.1 i2clk.0 mnemonic: i2c lk address: b eh bit name function 7 - 0 i2clk.[7:0] the i2c clock rate bits. i2c timer counter register bit: 7 6 5 4 3 2 1 0 - - - - - enti div4 tif mnemonic: i2timer address: b fh bit name function 7~3 - reserved. 2 enti enable i2c 14 - bits timer count er: 0: disable 14 - bits timer counter count. 1: enable 14 - bits timer counter count. after enable enti and ensi , the 14 - bit counter will be count ed. when si flag of i2c is set, the counter will stop to count and 14- bits timer counter will be cleared. 1 div4 i2c timer counter clock source divide function: 0: the 14 - bits ti mer counter source clock is f cpu clock. 1: the 14 - bits timer counter source clock is divided by 4. 0 tif the i2c timer counter count flag: 0: the 14 - bits timer counter is not overflow. 1: t he 14 - bits timer counter is overflow. before enable i2c timer ( both enti , ensi = [ 1 ,1 ] ) the si must be cleared. if i2c interrupt is enabled . t he i2c interrupt service routine will be executed. this bit is clear ed by software. i2c control register bit: 7 6 5 4 3 2 1 0 - ensi sta sto si aa - - mnemonic: i2con address: c0h bit name function 7 - reserved. 6 ens i 0: disable i2c serial function. the sda and scl output are in a high impedance state. sda and scl input signals are ignored, i2c is not in the ad dressed slave mode or it is not addressable, and sto bit in i2con is forced to ?0?. no other bits are affected. p1.3 (scl) and p1.2 (sda) may be used as open drain i/o ports. 1: enab le i2c serial function. the p1.2 and p1.3 port latches must be to logic 1. 5 sta start flag: 0: the sta bit is reset, no start condition or repeated start condition will
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 37 - revision a0 6 be generated. 1: the sta bit is set to enter a master mode. the i2c hardware checks the status of i2c bus and generates a start condition if the bus is free. i f bus is not free, then i2c waits for a stop condition and generates a start condition after a delay. if sta is set while i2c is already in a master mode and one or more bytes are transmitted or received, i2c transmits a repeated start condition. sta may b e set any time. sta may also be set when i2c interface is an addressed slave mode. 4 sto the bit sto bit is set while i2c is in a master mode. a stop condition is transmitted to the i2c bus. when the stop condition is detected on the bus, the i2c hardware clears the sto flag. in a slave mode, the sto flag may be set to recover from a bus error condition. in this case, no stop condition is transmitted to the i2c bus. however, the i2c hardware behaves as if a stop condition has been received and it switches to the not addressable slave receiver mode. the sto flag is automatically cleared by hardware. if the sta and sto bits are both set, then a stop condition is transmitted to the i2c bus if i2c is in a master mode (in a slave mode, i2c generates an internal stop condition which is not transmitted). i2c then transmits a start condition. 3 si 0 : when the si flag is reset, no serial interrupt is requested, and there is no stretching on the serial clock on the scl line. 1 : when a new i2c bus state is present in the i2 status register, the si flag is set by hardware, and, if the ea and es bits (in ie register) are both set, a serial interrupt is requested when si is set. the only state that does not cause si to be set is state f8h, which indicates that no relevant state information is available. when si is set, the low period of the serial clock on the scl line is stretched, and the serial transfer is suspended. a high level on the scl line is unaffected by the serial interrupt flag. si must be cleared by software. 2 aa assert acknowledge flag : 0: a not acknowledge (high level to sda) will be returned during the acknowledge clock pulse on scl when: 1) a data has been received while i2c is in the master receiver mode. 2) a data byte has been received while i2c is in the addressed slave receiver mode. 1: an acknowledge (low level to sda) will be returned during the acknowledge clock pulse on the scl line when: 1) the own slave address has been received. 2) a data byte has been received while i2c is in the master receiv er mode. 3) a data byte has been received while i2c is in the addressed slave receiver mode. 4) the general call address has been received while the general call bit (gc) in i2addr is set. 1~0 - reserved. i2c address register bit: 7 6 5 4 3 2 1 0 i2add r.7 i2addr.6 i2addr.5 i2addr.4 i2addr.3 i2addr.2 i2addr.1 gc mnemonic: i2addr address: c1h bit name function
preliminary n 79 e352/n79e352r data sheet - 38 - 7~1 i2addr.[7:1] i2c address register: the 8051 uc can read from and write to this 8 - bit, directly addressable sfr. the content of this register is irrelevant when i2c is in master mode. in the slave mode, the seven most significant bits must be loaded with the mcu?s own address. the i2c hardware will react if either of the address is matched. 0 gc general call function. 0: disable general call fu nction. 1: enable general call function. rommap bit: 7 6 5 4 3 2 1 0 ws 1 - - - 1 1 0 mnemonic: rommap address: c2 h bit name function 7 ws wait state signal enable. setting this bit enables the wait signal on p4.0. the devic e will sample the wait state control signal wait via p4.0 during movx instruction. this bit is time access protected. 6~0 - reserved. ta reg c7h rommap reg c2h ckcon reg 8eh mov ta,#aah mov ta,#55h orl rommap,#10000000b ; set ws bit to enable wait signal. power management register bit: 7 6 5 4 3 2 1 0 cd1 cd0 swb - - ale - off - - mnemonic: pmr address: c4 h bit name function
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 39 - revision a0 6 7~6 cd1~0 clock divide control. these bit selects the number of clocks required to generate on e machine cycle. there are three modes including divide by 4, 64 or 1024. switching between modes must first go back devide by 4 mode. for instance, to go from 64 to 1024 clocks/machine cycle the device must first go from 64 to 4 clocks/machine cycle, and then from 4 to 1024 clocks/machine cycle. cd1, cd0 clocks/machine cycle 0 x 4 1 0 64 1 1 1024 5 swb switchback enable. setting this bit allows an enabled external interrupt or serial port/ i2c activity to force the cd1, cd0 to divide by 4 state (0,x). the device wi ll switch modes at the start of the jump to interrupt service routine while a n external interrupt is enabled and actu ally recognized by microcontroller. while a serial port/ i2c receptio n, the switchback occurs at the start of the instruction following the falling edge of the start bit. note: changi ng swb bit is ignored during serial port / i2c activities. 4~3 - reserved. 2 ale - 0ff this bit disables the expression of the ale signal on the device pin during all on - board program and data m emory a ccesses. external memory acc esses will automatically enable ale independent of ale - off. 0 = ale expression is enable. 1 = ale expression is disable. 1~0 - reserved. status bit: 7 6 5 4 3 2 1 0 - - - - - - spta0 spra0 mnemonic: status address: c5h bi t name function 7 - 2 - reserved. 1 spta0 serial port 0 transmit activity. this bit is set during serial port 0 is currently tra nsmitting data. it is cleared when ti bit is set by hardware. changing the clock divide control bits cd0, cd1 will be ignored wh en this bit is set to 1 and swb = 1. 0 spra0 serial port 0 receive activity. this bit is set during serial port 0 is currently receiving a data. it is cleared when ri bit is set by hardware. changing the clock divide control bits cd0, cd1 will be ignored when this bit is set to 1 and swb = 1. nvm low byte address bit: 7 6 5 4 3 2 1 0
preliminary n 79 e352/n79e352r data sheet - 40 - - nvmadd r.6 nvmadd r.5 nvmadd r.4 nvmadd r.3 nvmadd r.2 nvmadd r.1 nvmadd r.0 mnemonic: nvmaddr address: c 6 h bit name function 7 - reserved 6 ~0 nvmaddr.[ 6 :0] the nvm address: the register indicate s nvm data memory address on on - chip code memory space. timed access bit: 7 6 5 4 3 2 1 0 ta.7 ta.6 ta.5 ta.4 ta.3 ta.2 ta.1 ta.0 mnemonic: ta address: c7h bit name function 7 - 0 ta.[7:0] the timed access register: the timed access register controls the access to protected bits. to access protected bits, the user must first write aah to the ta. this must be immediately followed by a write of 55h to ta. now a window is opened in the protected bits for three machine cycles, during whi ch the user can write to these bits. timer 2 control bit: 7 6 5 4 3 2 1 0 tf2 exf2 rclk tclk exen2 tr2 c t / 2 cp rl / 2 mnemonic: t2con address: c8h bit name function 7 t f2 timer 2 overflow flag: timer 2 overflow flag: this b it is set when timer 2 overflows. i t is also set when the count is equal to the capture register in down count mode. it can b e set only if rclk and tclk are both 0. it is cleared only by software. software can also set or clear this bit. 6 exf2 timer 2 ex ternal flag: a negative transition on the t2ex pin (p1.1) or timer 2 overflow will cause this flag to set based on the cp rl / 2 , exen2 and dcen bits. if set by a negative transition, this flag must be cleared by software. setting this bi t in so ftware or detection of a negative transition on t2ex pin will force a timer interrupt if enabled. 5 rclk receive clock flag: this bit determines the serial port t ime - base when receiving data in serial modes 1 or 3. if it is 0, then timer 1 overflow is use d for baud rate generation, otherwise timer 2 overflow is used. setting this bit forces timer 2 in baud rate generator mode.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 41 - revision a0 6 4 tclk transmit clock flag: this bit determines the serial port time - base when transmitting data in modes 1 and 3. if it is set to 0, the timer 1 overflow is used to generate the baud rate clock otherwise timer 2 overflow is used. setting this bit forces timer 2 in baud rate generator mode. 3 exen2 timer 2 external enable. this bit enables the capture/reload f unction on the t2ex pin if timer 2 is not generating baud clocks for the serial port. if this b it is 0, then the t2ex pin will be ignored, otherwise a negative transition detected on the t2e x pin will result in capture or reload. 2 tr2 timer 2 run control: this bit enables/dis ables the operation of timer 2. h alting this will preserve the current count in th2, tl2. 1 2 t / c counter/timer select. this bit determines whether timer 2 will function as a timer or a counter. independent of this bit, the timer will run a t 2 clocks per tick w hen used in baud rate generator mode. if it is set to 0, then timer 2 operates as a timer at a speed depending on t2m bit (ckcon.5), otherwise it will count negative edges on t2 pin. 0 2 rl / cp compare/reload select: this bit determines whether the cap ture or reload function will be used for timer 2. if either rclk or tclk is set, this bit wil l be ignored and the timer will function in an auto - reload mode following each overflow. if the bit is 0 then auto - reload will occur when timer 2 overflows or a falling edge is detected on t2e x pin if exen2 = 1. if this bit is 1, then timer 2 captures will occur when a falling edge is detected on t2ex pin if exen2 = 1. timer 2 mode control bit: 7 6 5 4 3 2 1 0 - - - icen0 t2cr 1 t2oe dcen mnemonic: t2mod address: c9h bit name function 7 ~ 5 - reserved. 4 icen0 e xternal input capture 0 enable: this bit enables input capture 0 on t0 pin. 3 t2cr timer 2 capture reset: in the timer 2 capture mode this bit enables/disables hardware auto matically reset timer 2 while the value in tl2 and th2 have been transferred into the capture register. 2 - must be 1 . 1 t2oe timer 2 output enable. this bit enables/disables the timer 2 clock out function. 0 dcen down count enable: this bit, in conjunc tion with the t2ex pin, controls the direction that timer 2 counts in 16 - bit auto - reload mode. timer 2 capture lsb bit: 7 6 5 4 3 2 1 0 rcap2l. rcap2l. rcap2l. rcap2l. rcap2l. rcap2l. rcap2l. rcap2l.
preliminary n 79 e352/n79e352r data sheet - 42 - 7 6 5 4 3 2 1 0 mnemonic: rcap2l address: cah bit name funct ion 7 - 0 rcap2l timer 2 capture lsb: this register is used to capture the tl2 value when a timer 2 is configured in capture mode.rcap2l is also used as the lsb of a 16 - bit reload value when timer 2 is configured in auto - reload mode.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 43 - revision a0 6 timer 2 capture msb bit: 7 6 5 4 3 2 1 0 rcap2 h . 7 rcap2 h . 6 rcap2 h . 5 rcap2 h . 4 rcap2 h . 3 rcap2 h . 2 rcap2 h . 1 rcap2 h . 0 mnemonic: rcap2h address: cbh bit name function 7 - 0 rcap2h timer 2 capture msb: this register is used to capture the th2 value when a timer 2 is configured in capture mode. rcap2h is also used as the msb of a 16 - bit reload value when timer 2 is configured in auto - reload mode. timer 2 lsb bit: 7 6 5 4 3 2 1 0 tl2.7 tl2.6 tl2.5 tl2.4 tl2.3 tl2.2 tl2.1 tl2.0 mnemonic: tl2 address: cch bit name function 7 - 0 tl 2 timer 2 lsb. timer 2 msb bit: 7 6 5 4 3 2 1 0 th2.7 th2.6 th2.5 th2.4 th2.3 th2.2 th2.1 th2.0 mnemonic: th2 address: cdh bit name function 7 - 0 tl2 timer 2 lsb. nvm control bit: 7 6 5 4 3 2 1 0 eer ewr ennvm - - - - - mnemonic: nvmcon address: ce h bit name function 7 eer nvm page(n) erase bit : 0: without erase nvm page(n). 1: set this bit to erase page(n) of nv m. the nvm has 8 pages and each page have 16 bytes data memory. initiate page select by programming nvmaddl register s, which will automati cally enable page area . when user set this bit, the page erase process will begin and program counter will halt at this instruction. after the erase process is completed , program counter will continue executing next instruction . 6 ewr nvm data write bit : 0: without write nvm data.
preliminary n 79 e352/n79e352r data sheet - 44 - 1: set this bit to write nvm bytes and program counter will halt at this instruction. after write is finished, program counter will kept next instruction then executed. 5 ennvm to enable read nvm data m emory area. 0: to disable the movx instruction to read nvm data memory. 1: to enable the movx instruction to read nvm data memory, the external ram or aux - ram will be disabled. 4 - 0 - reserved nvm data bit: 7 6 5 4 3 2 1 0 nvmdat. 7 nvmdat. 6 nvmdat. 5 nvmdat. 4 nvmdat 3 nvmdat. 2 nvm dat. 1 nvmdat. 0 mnemonic: nvmdata address: cfh bit name function 7~0 nvmdat.[7:0] the nvm data write register. the read nvm data is by movc instruction. program status word bit: 7 6 5 4 3 2 1 0 cy ac f0 rs1 rs0 ov f1 p mnemonic: psw address: d0h bit n ame function 7 cy carry flag: set for an arithmetic operation which results in a carry being generated from the alu. it is also used as the accumulator for the bit operations. 6 ac auxiliary carry: set when the previous operation resulted in a carry fro m the high order nibble. 5 f0 user flag 0: the general purpose flag that can be set or cleared by the user. 4~3 rs1~rs0 register bank select bits. 2 ov overflow flag: set when a carry was generated from the seventh bit but not from the 8th bit as a res ult of the previous operation, or vice - versa. 1 f1 user flag 1: the general purpose flag that can be set or cleared by the user software . 0 p parity flag: set/cleared by hardware to indicate odd/even number of 1's in the accumulator. rs.1 - 0: register b ank s elect ion b its:
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 45 - revision a0 6 rs1 rs0 register b ank address 0 0 0 00 - 07h 0 1 1 08 - 0fh 1 0 2 10 - 17h 1 1 3 18 - 1fh pwm control register 3 bit: 7 6 5 4 3 2 1 0 - - pwm1 oe pwm0oe pclk.1 pclk.0 fp1 fp0 mnemonic: pwmcon3 address: d7h bit name function 7 ~6 - reserv ed. 5 pwm1oe pwm1 output enable bit. 0: pwm1 output disabled. 1: pwm1 output enabled. 4 pwm0oe pwm0 output enable bit. 0: pwm0 output disabled. 1: pwm0 output enabled. 3~2 pclk.1~0 pwm clock source selection bits , see below table. pclk [1:0] pwm clock s ource 00 fosc 01 timer 0 overflow 10 timer 1 overflow 11 reserved 1 ~0 fp1~0 select pwm frequency pre - scale select bits , see belowtable. fp[1:0] fpwm 00 f pclk /1 (default) 01 f pclk /2 10 f pclk /4 11 f pclk /8 watchdog control bit: 7 6 5 4 3 2 1 0 wdrun por - - wdif wtrf ewrst wdclr mnemonic: wdcon address: d8h bit name function
preliminary n 79 e352/n79e352r data sheet - 46 - 7 wdrun 0: the watchdog is stopped. 1: the watchdog is running. 6 por power - on reset flag. hardware will set this flag on a power up condition. this flag can be read or written by software. a write by software is the only way to clear this bit once it is set. 5~4 - reserved. 3 wdif watchdog timer interrupt flag: 0: if the interrupt is not enabled, then this bit indicates that the time - out period has elapsed. this bit mu st be cleared by software. 1: if the watchdog interrupt is enabled, hardware will set this bit to indicate that the watchdog interrupt has occurred. 2 wtrf watchdog timer reset flag: 1: hardware will set this bit when the watchdog timer causes a reset. so ftware can read it but must clear it manually. a power - fail reset will also clear the bit. this bit helps software in determining the cause of a reset. if ewrst = 0, the watchdog timer will have no affect on this bit. 1 ewrst 0: disable watchdog timer res et. 1: enable watchdog timer reset. 0 wdclr reset watchdog timer: this bit helps in putting the watchdog timer into a know state. it also helps in resetting the watchdog timer before a time - out occurs. failing to set the ewrst before time - out will cause a n interrupt (if ewdi ( e ie.4) is set), and 512 clocks after that a watchdog timer reset will be generated (if ewrst is set). this bit is self - clearing by hardware. the wdcon sfr is set to a 01 xx 0000b on a power - on- reset. wtrf (wdcon.2) is set to a 1 on a w atchdog timer reset, but to a 0 on power on/down resets. wtrf (wdcon.2) is not altered by an external reset. ewrst (wdcon.1) is set to 0 on all resets. all the bits in this sfr have unrestric ted read access. wdrun, por , ewrst, wdif and wdclr require timed access procedure to write. the remaining bits have unrestricted write accesses. please refer ta register description. ta reg c7h wdcon reg d8h mov ta, #aah ; to access protected bits mov ta, #55h setb wdcon.0 ; reset watchdog timer orl wd con, # 00110000b ; select 26 bits watchdog timer mov ta, #aah mov ta, #55h orl wdcon, #1 0000010b ; enable watchdog pwm 0 low bits register bit: 7 6 5 4 3 2 1 0
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 47 - revision a0 6 pwm0.7 pwm0.6 pwm0.5 pwm0.4 pwm0.3 pwm0.2 pwm0.1 pwm0.0 mnemonic: pwm0l a ddress: dah bit name function 7~0 pwm0 pwm 0 low bits register. pwm 0 low bits register bit: 7 6 5 4 3 2 1 0 pwm1 .7 pwm1 .6 pwm1 .5 pwm1 .4 pwm1 .3 pwm1 .2 pwm1 .1 pwm1.0 mnemonic: pwm1 l a ddress: db h bit name function 7~0 pwm1 pwm 1 low bits register. pwm control register 1 bit: 7 6 5 4 3 2 1 0 pwmrun - - clrpwm - - - - mnemonic: p wmcon1 address: dch bit name function 7 pwmrun 0: the pwm is not running. 1: the pwm counter is running. 6 ~5 - reserved. 4 clrpwm 1: cle ar 8 - bit pwm counter to 000h. it is automatically clear ed by hardware. 3~ 0 - reserved. accumulator bit: 7 6 5 4 3 2 1 0 acc.7 acc.6 acc.5 acc.4 acc.3 acc.2 acc.1 acc.0 mnemonic: acc address: e0h bit name function 7 - 0 acc the a or acc register is the standard 8052 accumulator. input capture 0 low registe r bit: 7 6 5 4 3 2 1 0 ccl0.7 ccl0.6 ccl0.5 ccl0.4 ccl0.3 ccl0.2 ccl0.1 ccl0.0 mnemonic: ccl0 address: e4 h bit name function 7 - 0 ccl0 capture 0 low byte.
preliminary n 79 e352/n79e352r data sheet - 48 - input capture 0 high register bit: 7 6 5 4 3 2 1 0 cch 0.7 cch 0.6 cch 0.5 cch 0.4 cch 0.3 cch 0.2 cch 0.1 cch 0.0 mnemonic: cch0 address: e4 h bit name function 7 - 0 cch 0 capture 0 high byte. iinterrupt enable register 1 bit: 7 6 5 4 3 2 1 0 ecptf ebo - ewdi - - ekb ei2 mnemonic: eie address: e 8 h bit name function 7 ecptf 0: disable capture interrupt . 1: enable capture interrupt . 6 e bo enable brownout interrupt. 0: disable brownout interrupt . 1: enable brownout interrupt . 5 - reserved. 4 ewdi 0: disable watchdog timer interrupt. 1: enable watchdog timer interrupt. 3 ~2 - reserved. 1 ekb 0: disable keypad interrupt. 1: enable keypad interrupt. 0 ei2 0: disable i2c interrupt. 1: enable i2c interrupt. keyboard level bit: 7 6 5 4 3 2 1 0 kbl.7 kbl.6 kbl.5 kbl.4 kbl.3 kbl.2 kbl.1 kbl.0 mnemonic: kbl address: e 9 h bit name function 7~0 kbl.7~0 keyb oard trigger level . 0: low level t rigger .x pin. 1: high level trigger on kbi.x pin. [x = 0 - 7] p orts shmitt register bit: 7 6 5 4 3 2 1 0
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 49 - revision a0 6 - - p5s - p3s p2s p1s p0s mnemonic: ports address: ech bit name function 7~6 - reserved. 5 p5 s 1: enables schmit t trigger inputs on port 5 . 4 - reserved. 3 p 3 s 1: enables schmitt trigger inputs on port 3 . 2 p2s 1: enables schmitt trigger inputs on port 2. 1 p1s 1: enables schmitt trigger inputs on port 1. 0 p0s 1: enables schmitt trigger inputs on port 0. port 5 output mode 1 bit: 7 6 5 4 3 2 1 0 - - - - - enclk p5m1.1 p5m1.0 mnemonic: p5m1 address: edh bit name function 7~3 - reserved. 2 enclk 1: enabled clock output to xtal2 pin (p5.0). 1 ~0 p5m1.1 ~0 to control the output configuration of p5 bits [1:0] . p ort 5 output mode 2 bit: 7 6 5 4 3 2 1 0 - - - - - - p5m 2 .1 p5m 2 .0 mnemonic: p5m2 address: eeh bit name function 7~2 - reserved. 1~0 p5m2 .1 ~0 to control the output configuration of p5 bits [1:0] . b register bit: 7 6 5 4 3 2 1 0 b.7 b.6 b.5 b.4 b.3 b.2 b.1 b.0 mnemonic: b address: f0h bit name function 7 - 0 b the b register is the standard 8052 register that serves as a second accumulator. interrupt high priority 1 bit: 7 6 5 4 3 2 1 0
preliminary n 79 e352/n79e352r data sheet - 50 - pcaph pboh - pwdih - - pkbh pi2h mnemonic: ip1 h address: f 7 h bit name function 7 pcaph 1: to set interrup t high priority of input capture 0 as highest priority level. 6 p boh 1: to set interrupt high priority of brownout is highest priority level. 5 - reserved. 4 pwdih 1: to set interrupt high priority of wa tchdog is highe st priority level. 3 ~2 - reserved. 1 pkbh 1: to set interrupt high priority of keypad is highe st priority level. 0 pi2h 1: to set interrupt high priority of i2c is highe st priority level. interrupt priority 1 bit: 7 6 5 4 3 2 1 0 pcap pbo - pwdi - - pkb pi2 mnemonic: ip1 address: f8h bit name function 7 pcap 1: to set int errupt priority of input capture 0 as higher priority level. 6 p bo 1: to set interrupt priority of brownout is higher priority level. 5 - reserved. 4 pwdi 1: to se t interrupt priority of watchdog is higher priority level. 3~2 - reserved. 1 pkb 1: to set interrupt priority of keypad is higher priority level. 0 pi2 1: to set interrupt priority of i2c is higher priority level.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 51 - revision a0 6 9. instruction the n79e352(r) executes all the instructions of the standard 8052 family. the operation of these instructions, their effect on the flag bits and the status bits is exactly the same. however, timing of these instructions is different. the reason for this is two fold. firstly, in t he n79e352(r) , each machine cycle consists of 4 clock periods, while in the standard 8052 it consists of 12 clock periods. also, in the n79e352(r) there is only one fetch per machine cycle i.e. 4 clocks per fetch, while in the standard 8052 there can be tw o fetches per machine cycle, which works out to 6 clocks per fetch. the advantage the n79e352(r) has is that since there is only one fetch per machine cycle, the number of machine cycles in most cases is equal to the number of operands that the instruction has. in case of jumps and calls there will be an additional cycle that will be needed to calculate the new address. but overall the n79e352(r) reduces the number of dummy fetches and wasted cycles, thereby improving efficiency as compared to the standard 8052. table 9 - 1 : instructions that affect flag settings instruction carry overflow auxiliary carry instruction carry overflow auxiliary carry add x x x clr c 0 addc x x x cpl c x subb x x x anl c, bit x mul 0 x anl c, bit x div 0 x orl c, bit x da a x orl c, bit x rrc a x mov c, bit x rlc a x cjne x setb c 1 a "x" indicates that the modification is as per the result of instruction.
preliminary n 79 e352/n79e352r data sheet - 52 - table 9 - 2 : instruction timing for n79e352(r) instruction hex op - code bytes n79e352(r) machine cycles n79e352(r) clock cycles 8052 clock cycles n79e352(r) vs. 8052 speed ratio nop 00 1 1 4 12 3 add a, r0 28 1 1 4 12 3 add a, r1 29 1 1 4 12 3 add a, r2 2a 1 1 4 12 3 add a, r3 2b 1 1 4 12 3 add a, r4 2c 1 1 4 12 3 add a, r5 2d 1 1 4 12 3 add a, r6 2e 1 1 4 12 3 add a, r7 2f 1 1 4 12 3 add a, @r0 26 1 1 4 12 3 add a, @r1 27 1 1 4 12 3 add a, direct 25 2 2 8 12 1.5 add a, #data 24 2 2 8 12 1.5
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 53 - revision a0 6 instruction timing for n79e352(r) , continued instruction hex op - code bytes n79e352(r) machine cycles n79e352(r) clock cycles 8052 clock cycles n79e352(r) vs. 8052 speed ratio addc a, r0 38 1 1 4 12 3 addc a, r1 39 1 1 4 12 3 addc a, r2 3 a 1 1 4 12 3 addc a, r3 3b 1 1 4 12 3 addc a, r4 3c 1 1 4 12 3 addc a, r5 3d 1 1 4 12 3 addc a, r6 3e 1 1 4 12 3 addc a, r7 3f 1 1 4 12 3 addc a, @r0 36 1 1 4 12 3 addc a, @r1 37 1 1 4 12 3 addc a, direct 35 2 2 8 12 1.5 addc a, #data 34 2 2 8 12 1.5 acall addr11 71, 91, b1, 11, 31, 51, d1, f1 2 3 12 24 2 ajmp addr11 01, 21, 41, 61, 81, a1, c1, e1 2 3 12 24 2 anl a, r0 58 1 1 4 12 3 anl a, r1 59 1 1 4 12 3 anl a, r2 5a 1 1 4 12 3 anl a, r3 5b 1 1 4 12 3 anl a, r4 5c 1 1 4 12 3 anl a, r5 5d 1 1 4 12 3 anl a, r6 5e 1 1 4 12 3 anl a, r7 5f 1 1 4 12 3 anl a, @r0 56 1 1 4 12 3 anl a, @r1 57 1 1 4 12 3 anl a, direct 55 2 2 8 12 1.5 anl a, #data 54 2 2 8 12 1.5 anl direct, a 52 2 2 8 12 1.5 anl direct, #data 53 3 3 12 24 2 anl c, bit 82 2 2 8 24 3 anl c, /bit b0 2 2 8 24 3 cjne a, direct, rel b5 3 4 16 24 1.5 cjne a, #data, rel b4 3 4 16 24 1.5 cjne @r0, #data, rel b6 3 4 16 24 1.5 cjne @r1, #data, rel b7 3 4 16 24 1.5 cjne r0, #data, rel b8 3 4 16 24 1.5 cjne r1, #data, rel b9 3 4 1 6 24 1.5 cjne r2, #data, rel ba 3 4 16 24 1.5 cjne r3, #data, rel bb 3 4 16 24 1.5 cjne r4, #data, rel bc 3 4 16 24 1.5 cjne r5, #data, rel bd 3 4 16 24 1.5 cjne r6, #data, rel be 3 4 16 24 1.5
preliminary n 79 e352/n79e352r data sheet - 54 - instruction timing for n79e352(r) , continued instructi on hex op - code bytes n79e352(r) machine cycles n79e352(r) clock cycles 8052 clock cycles n79e352(r) vs. 8052 speed ratio clr a e4 1 1 4 12 3 cpl a f4 1 1 4 12 3 clr c c3 1 1 4 12 3 clr bit c2 2 2 8 12 1.5 cpl c b3 1 1 4 12 3 cpl bit b2 2 2 8 12 1.5 dec a 14 1 1 4 12 3 dec r0 18 1 1 4 12 3 dec r1 19 1 1 4 12 3 dec r2 1a 1 1 4 12 3 dec r3 1b 1 1 4 12 3 dec r4 1c 1 1 4 12 3 dec r5 1d 1 1 4 12 3 dec r6 1e 1 1 4 12 3 dec r7 1f 1 1 4 12 3 dec @r0 16 1 1 4 12 3 dec @r1 17 1 1 4 12 3 dec direct 15 2 2 8 12 1.5 dec dptr a5 1 2 8 - - div ab 84 1 5 20 48 2.4 da a d4 1 1 4 12 3 djnz r0, rel d8 2 3 12 24 2 djnz r1, rel d9 2 3 12 24 2 djnz r5, rel dd 2 3 12 24 2 djnz r2, rel da 2 3 12 24 2 djnz r3, rel db 2 3 12 24 2 djnz r4, rel dc 2 3 12 24 2 djnz r6, rel de 2 3 12 24 2 djnz r7, rel df 2 3 12 24 2 djnz direct, rel d5 3 4 16 24 1.5 inc a 04 1 1 4 12 3 inc r0 08 1 1 4 12 3 inc r1 09 1 1 4 12 3 inc r2 0a 1 1 4 12 3 inc r3 0b 1 1 4 12 3 inc r4 0c 1 1 4 12 3
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 55 - revision a0 6 instruction timing for n79e 352(r) , continued instruction hex op - code bytes n79e352(r) machine cycles n79e352(r) clock cycles 8052 clock cycles n79e352(r) vs. 8052 speed ratio inc r6 0e 1 1 4 12 3 inc r7 0f 1 1 4 12 3 inc @r0 06 1 1 4 12 3 inc @r1 07 1 1 4 12 3 inc direct 05 2 2 8 12 1.5 inc dptr a3 1 2 8 24 3 jmp @a+dptr 73 1 2 8 24 3 jz rel 60 2 3 12 24 2 jnz rel 70 2 3 12 24 2 jc rel 40 2 3 12 24 2 jnc rel 50 2 3 12 24 2 jb bit, rel 20 3 4 16 24 1.5 jnb bit, rel 30 3 4 16 24 1.5 jbc bit, rel 10 3 4 16 24 1.5 lcall addr16 12 3 4 16 24 1.5 ljmp addr16 02 3 4 16 24 1.5 mul ab a4 1 5 20 48 2.4 mov a, r0 e8 1 1 4 12 3 mov a, r1 e9 1 1 4 12 3 mov a, r2 ea 1 1 4 12 3 mov a, r3 eb 1 1 4 12 3 mov a, r4 ec 1 1 4 12 3 mov a, r5 ed 1 1 4 12 3 mov a, r6 ee 1 1 4 12 3 m ov a, r7 ef 1 1 4 12 3 mov a, @r0 e6 1 1 4 12 3 mov a, @r1 e7 1 1 4 12 3 mov a, direct e5 2 2 8 12 1.5 mov a, #data 74 2 2 8 12 1.5 mov r0, a f8 1 1 4 12 3 mov r1, a f9 1 1 4 12 3 mov r2, a fa 1 1 4 12 3 mov r3, a fb 1 1 4 12 3 mov r4, a fc 1 1 4 12 3 mov r5, a fd 1 1 4 12 3 mov r6, a fe 1 1 4 12 3 mov r7, a ff 1 1 4 12 3
preliminary n 79 e352/n79e352r data sheet - 56 - instruction timing for n79e352(r) , continued instruction hex op - code bytes n79e352(r) machine cycles n79e352(r) clock cycles 8052 clock cycles n79e352(r) vs. 8052 speed r atio mov r1, direct a9 2 2 8 12 1.5 mov r2, direct aa 2 2 8 12 1.5 mov r3, direct ab 2 2 8 12 1.5 mov r4, direct ac 2 2 8 12 1.5 mov r5, direct ad 2 2 8 12 1.5 mov r6, direct ae 2 2 8 12 1.5 mov r7, direct af 2 2 8 12 1.5 mov r0, #data 78 2 2 8 12 1.5 mov r1, #data 79 2 2 8 12 1.5 mov r2, #data 7a 2 2 8 12 1.5 mov r3, #data 7b 2 2 8 12 1.5 mov r4, #data 7c 2 2 8 12 1.5 mov r5, #data 7d 2 2 8 12 1.5 mov r6, #data 7e 2 2 8 12 1.5 mov r7, #data 7f 2 2 8 12 1.5 mov @r0, a f6 1 1 4 12 3 mov @r1, a f7 1 1 4 12 3 mov @r0, direct a6 2 2 8 12 1.5 mov @r1, direct a7 2 2 8 12 1.5 mov @r0, #data 76 2 2 8 12 1.5 mov @r1, #data 77 2 2 8 12 1.5 mov direct, a f5 2 2 8 12 1.5 mov direct, r0 88 2 2 8 12 1.5 mov direct, r1 89 2 2 8 12 1.5 mov direct, r 2 8a 2 2 8 12 1.5 mov direct, r3 8b 2 2 8 12 1.5 mov direct, r4 8c 2 2 8 12 1.5 mov direct, r5 8d 2 2 8 12 1.5 mov direct, r6 8e 2 2 8 12 1.5 mov direct, r7 8f 2 2 8 12 1.5 mov direct, @r0 86 2 2 8 12 1.5 mov direct, @r1 87 2 2 8 12 1.5 mov direct, direct 85 3 3 12 24 2 mov direct, #data 75 3 3 12 24 2 mov dptr, #data 16 90 3 3 12 24 2 movc a, @a+dptr 93 1 2 8 24 3
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 57 - revision a0 6 instruction timing for n79e352(r) , continued instruction hex op - code bytes n79e352(r) machine cycles n79e352(r) clock cycles 8052 clock cycles n79e352(r) vs. 8052 speed ratio movx a, @r0 e2 1 2 - 9 8 - 36 24 3 - 0.66 movx a, @r1 e3 1 2 - 9 8 - 36 24 3 - 0.66 movx a, @dptr e0 1 2 - 9 8 - 36 24 3 - 0.66 movx @r0, a f2 1 2 - 9 8 - 36 24 3 - 0.66 movx @r1, a f3 1 2 - 9 8 - 36 24 3 - 0.66 movx @dptr, a f0 1 2 - 9 8 - 36 24 3 - 0.66 mov c, bit a2 2 2 8 12 1.5 mov bit, c 92 2 2 8 24 3 orl a, r0 48 1 1 4 12 3 orl a, r1 49 1 1 4 12 3 orl a, r2 4a 1 1 4 12 3 orl a, r3 4b 1 1 4 12 3 orl a, r4 4c 1 1 4 12 3 orl a, r5 4d 1 1 4 12 3 orl a, r6 4e 1 1 4 12 3 orl a, r7 4f 1 1 4 12 3 orl a, @r0 46 1 1 4 12 3 orl a, @r1 47 1 1 4 12 3 orl a, direct 45 2 2 8 12 1.5 orl a, #data 44 2 2 8 12 1.5 orl direct, a 42 2 2 8 12 1.5 orl direct, #data 43 3 3 12 24 2 orl c, bit 72 2 2 8 24 3 orl c, /bit a0 2 2 6 24 3 push direct c0 2 2 8 24 3 pop direct d0 2 2 8 24 3 ret 22 1 2 8 24 3 reti 32 1 2 8 24 3 rl a 23 1 1 4 12 3 rlc a 33 1 1 4 12 3 rr a 03 1 1 4 12 3 rrc a 13 1 1 4 12 3 setb c d3 1 1 4 12 3 setb bit d2 2 2 8 12 1.5 swap a c4 1 1 4 12 3 sjmp rel 80 2 3 12 24 2 subb a, r0 98 1 1 4 12 3
preliminary n 79 e352/n79e352r data sheet - 58 - instruction timing for n79e352(r) , continued instruction hex op - code bytes n79e352(r) machine cycles n79e352(r) clock cycles 8052 clock cycles n79e352(r) vs. 8052 speed ratio subb a, r2 9a 1 1 4 12 3 subb a, r3 9b 1 1 4 12 3 subb a, r4 9c 1 1 4 12 3 subb a, r5 9d 1 1 4 12 3 subb a, r6 9e 1 1 4 12 3 subb a, r7 9f 1 1 4 12 3 subb a, @r0 96 1 1 4 12 3 subb a, @r1 97 1 1 4 12 3 subb a, direct 95 2 2 8 12 1.5 subb a, #data 94 2 2 8 1 2 1.5 xch a, r0 c8 1 1 4 12 3 xch a, r1 c9 1 1 4 12 3 xch a, r2 ca 1 1 4 12 3 xch a, r3 cb 1 1 4 12 3 xch a, r4 cc 1 1 4 12 3 xch a, r5 cd 1 1 4 12 3 xch a, r6 ce 1 1 4 12 3 xch a, r7 cf 1 1 4 12 3 xch a, @r0 c6 1 1 4 12 3 xch a, @r1 c7 1 1 4 12 3 xchd a, @r0 d6 1 1 4 12 3 xchd a, @r1 d7 1 1 4 12 3 xch a, direct c5 2 2 8 12 1.5 xrl a, r0 68 1 1 4 12 3 xrl a, r1 69 1 1 4 12 3 xrl a, r2 6a 1 1 4 12 3 xrl a, r3 6b 1 1 4 12 3 xrl a, r4 6c 1 1 4 12 3 xrl a, r5 6d 1 1 4 12 3 xrl a, r6 6e 1 1 4 12 3 xrl a, r7 6f 1 1 4 12 3 xrl a, @r0 66 1 1 4 12 3 xrl a, @r1 67 1 1 4 12 3 xrl a, direct 65 2 2 8 12 1.5 xrl a, #data 64 2 2 8 12 1.5 xrl direct, a 62 2 2 8 12 1.5 xrl direct, #data 63 3 3 12 24 2 9.1 instruction timing
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 59 - revision a0 6 the instruction timing fo r the n79e352(r) is an important aspect, especially for those users who wish to use software instructions to generate timing delays. also, it provides the user with an insight into the timing differences between the n79e352(r) and the standard 8052 . in the n79e352(r) each machine cycle is four clock periods long. each clock period is designated a state. thus each machine cycle is made up of four states, c1, c2 c3 and c4, in that order. due to the reduced time for each instruction execution, both the clock e dges are used for internal timing. hence it is important that the duty cycle of the clock be as close to 50% as possible to avoid timing conflicts. as mentioned earlier, the n79e352(r) does one op - code fetch per machine cycle. therefore, in most of the in structions, the number of machine cycles needed to execute the instruction is equal to the number of bytes in the instruction. of the 256 available op - codes, 128 of them are single cycle instructions. thus more than half of all op - codes in the n79e352(r) a re executed in just four clock periods. most of the two - cycle instructions are those that have two byte instruction codes. however there are some instructions that have only one byte instructions, yet they are two cycle instructions. one instruction which is of importance is the movx instruction. in the standard 8052 , the movx instruction is always two machine cycles long. however in the n79e352(r) , the user has a facility to stretch the duration of this instruction from 2 machine cycles to 9 machine cycles . the rd and wr strobe lines are also proportionately elongated. this gives the user flexibility in accessing both fast and slow peripherals without the use of external circuitry and with minimum software overhead. the r est of the instructions are either three, four or five machine cycle instructions. note that in the n79e352(r) , based on the number of machine cycles, there are five different types, while in the standard 8052 there are only three. however, in the n79e352( r) each machine cycle is made of only 4 clock periods compared to the 12 clock periods for the standard 8052 . therefore, even though the number of categories has increased, each instruction is at least 1.5 to 3 times faster than the standard 8052 in terms of clock periods. single cycle c4 c3 c2 c1 clk ale psen ad7-0 port 2 a7-0 address a15-8 data_ in d7-0 figure 9 - 1 : single cycle instruction timing
preliminary n 79 e352/n79e352r data sheet - 60 - instruction fetch c4 c3 c2 c1 op-code address a15-8 address a15-8 ale psen pc ad7-0 port 2 clk operand fetch c4 c3 c2 c1 operand pc+1 figure 9 - 2 : two cycle instruction timing operand operand a7-0 a7-0 a7-0 op-code address a15-8 address a15-8 address a15-8 operand fetch operand fetch instruction fetch c2 c3 c4 c2 c3 c4 c4 c3 c2 c1 c1 c1 clk ale psen ad7-0 port 2 figure 9 - 3 : three cycle instruction timing
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 61 - revision a0 6 operand operand operand op-code address a15-8 address a15-8 address a15-8 address a15-8 a7-0 a7-0 a7-0 a7-0 operand fetch operand fetch operand fetch instruction fetch c2 c1 c4 c3 c2 c1 clk ale psen ad7-0 port 2 c4 c3 c2 c1 c4 c3 c2 c1 c4 c3 figure 9 - 4 : four cycle instruction timing operand operand operand op-code address a15-8 address a15-8 address a15-8 address a15-8 a7-0 a7-0 a7-0 a7-0 operand fetch operand fetch operand fetch operand fetch instruction fetch c2 c1 c4 c3 c2 c1 clk ale psen ad7-0 port 2 c4 c3 c2 c1 c4 c3 c2 c1 c4 c3 c2 c1 c4 c3 operand a7-0 address a15-8 figure 9 - 5 : five cycle instruction timing
preliminary n 79 e352/n79e352r data sheet - 62 - 9.2 movx instruction the n79e352(r) , like the standard 8052 , uses the movx instruction to access external data memory. this data memory includes both off - c hip memory as well as memory mapped peripherals. while the results of the movx instruction are the same as in the standard 8052 , the operation and the timing of the strobe signals have been modified in order to give the user much greater flexibility. the m ovx instruction is of two types, the movx @ri and movx @dptr. in the movx @ri, the address of the external data comes from two sources. the lower 8 - bits of the address are stored in the ri register of the selected working register bank. the upper 8 - bits of the address come from the port 2 sfr. in the movx @dptr type, the full 16 - bit address is supplied by the data pointer. since the n79e352(r) has two data pointers, dptr and dptr1, the user has to select between the two by setting or clearing the dps bit. t he data pointer select bit (dps) is the lsb of the dps sfr, which exists at location 86h. no other bits in this sfr have any effect, and they are set to 0. when dps is 0, then dptr is selected, and when set to 1, dptr1 is selected. the user can switch betw een dptr and dptr1 by toggling the dps bit. the quickest way to do this is by the inc instruction. the advantage of having two data pointers is most obvious while performing block move operations. the accompanying code shows how the use of two separate dat a pointers speeds up the execution time for code performing the same task. block move with single data pointer: ; sh and sl are the high and low bytes of source address ; dh and dl are the high and low bytes of destination address ; cnt is the number of b ytes to be moved machine cycles of n79e352(r) # mov r2, #cnt ; load r2 with the count value 2 mov r3, #sl ; save low byte of source address in r3 2 mov r4, #sh ; save high byte of source address in r4 2 mov r5, #dl ; save low byte of d estination address in r5 2 mov r6, #dh ; save high byte of destination address in r6 2 loop: mov dpl, r3 ; load dpl with low byte of source address 2 mov dph, r4 ; load dph with high byte of source address 2 movx a, @dptr ; get byte from source to accumulator 2 inc dptr ; increment source address to next byte 2 mov r3, dpl ; save low byte of source address in r3 2 mov r4, dph ; save high byte of source address in r4 2 mov dpl, r5 ; load low byte of destination address in dpl 2 mov dph, r6 ; load high byte of destination address in dph 2 movx @dptr, a ; write data to destination 2 inc dptr ; increment destination address 2 mov dpl, r5 ; save low byte of new destination address in r5 2 mov dph, r6 ; save high byte of new dest ination address in r6 2 djnz r2, loop ; decrement count and do loop again if count <> 0 2
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 63 - revision a0 6 machine cycles in standard 8052 = 10 + (26 * cnt) machine cycles in n79e352(r) = 10 + (26 * cnt) if cnt = 50 clock cycles in standard 8052 = ((10 + (26 *50)) * 12 = (10 + 1300) * 12 = 15720 clock cycles in n79e352(r) = ((10 + (26 * 50)) * 4 = (10 + 1300) * 4 = 5240 block move with two data pointers in n79e352(r) : ; sh and sl are the high and low bytes of source address ; dh and dl are the high and low bytes of destin ation address ; cnt is the number of bytes to be moved machine cycles of n79e352(r) # mov r2, #cnt ; load r2 with the count value 2 mov dps, #00h ; clear dps to point to dptr 2 mov dptr, #dhdl ; load dptr with destination address 3 inc dps ; set dps to point to dptr1 2 mov dptr, #shsl ; load dptr1 with source address 3 loop: movx a, @dptr ; get data from source block 2 inc dptr ; increment source address 2 dec dps ; clear dps to point to dptr 2 movx @dptr, a ; write data to destina tion 2 inc dptr ; increment destination address 2 inc dps ; set dps to point to dptr1 2 djnz r2, loop ; check if all done 3 machine cycles in n79e352(r) = 12 + (15 * cnt) if cnt = 50 clock cycles in n79e352(r) = (12 + (15 * 50)) * 4 = (12 + 750) * 4 = 3048 we can see that in the first program the standard 8052 takes 15720 cycles, while the n79e352(r) takes only 5240 cycles for the same code. in the second program, written for the n79e352(r) , program execution requires only 3048 clock cycles. if t he size of the block is increased then the saving is even greater. 9.3 external data memory access timing the timing for the movx instruction is another feature of the n79e352(r) . in the standard 8052 , the movx instruction has a fixed execution time of 2 machi ne cycles. however in the n79e352(r) , the duration of the access can be varied by the user. the instruction starts off as a normal op - code fetch of 4 clocks. in the next machine cycle, the n79e352(r) puts out the address of the external data memory and the actual access occurs here. the user can change the duration of this access time by setting the stretch value. the clock control sfr (ckcon) has three bits that control the stretch value. these three bits are m2 - 0 (bits 2 - 0 of ckcon). these three bits give the user 8 different access time options. the stretch can be varied from 0 to 7, resulting in movx instructions that last from 2 to 9 machine cycles in length. note that the stretching of the instruction only results in the elongation of the movx instruct ion, as if the state of the cpu was held for the desired period. there is no effect on any other instruction or its timing. by
preliminary n 79 e352/n79e352r data sheet - 64 - default, the stretch value is set at 1, giving a movx instruction of 3 machine cycles. if desired by the user the stretch value c an be set to 0 to give the fastest movx instruction of only 2 machine cycles. table 9 - 3 : data memory cycle stretch values m2 m1 m0 machine cycles rd or wr strobe width in clocks rd or wr strobe width @ 20 mhz 0 0 0 2 2 100 ns 0 0 1 3 (default) 4 200 ns 0 1 0 4 8 400 ns 0 1 1 5 12 600 ns 1 0 0 6 16 800 ns 1 0 1 7 20 1000 ns 1 1 0 8 24 1200 ns 1 1 1 9 28 1400 ns next instruction machine cycle second machine cycle first machine cycle last cycle of previous instruction c4 port 2 port 0 wr psen ale clk c3 c2 d0-d7 a0-a7 d0-d7 a0-a7 d0-d7 a0-a7 d0-d7 a15-a8 a15-a8 a15-a8 a15-a8 a0-a7 c1 c4 c3 c2 c1 c4 c3 c2 c1 c4 c3 c2 c1 movx instruction cycle next inst. read next inst. address movx data out movx data address movx inst. address movx inst . figure 9 - 6 : data memory write with stretch value = 0
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 65 - revision a0 6 next instruction machine cycle third machine cycle second machine cycle first machine cycle last cycle of previous instruction c4 port 2 port 0 wr psen ale clk c3 c2 d0-d7 a0-a7 d0-d7 a0-a 7 d0-d7 a0-a7 d0-d7 a15-a8 a15-a8 a15-a8 a15-a8 a0-a7 c1 c4 c3 c2 c1 c4 c3 c2 c1 c4 c3 c2 c1 movx instruction cycle next inst. read next inst. address movx data out movx data address movx inst. address movx inst. c4 c3 c2 c1 figure 9 - 7 : data memory write with stretch value = 1
preliminary n 79 e352/n79e352r data sheet - 66 - next instruction machine cycle fourth machine cycle third machine cycle second machine cycle first machine cycle last cycle of previous instruction c4 port 2 port 0 wr psen ale clk c3 c2 d0-d7 a0-a7 d0-d7 a0-a7 d0-d7 a0-a7 d0-d7 a15-a8 a15-a8 a15-a8 a15-a8 a0-a7 c1 c4 c3 c2 c1 c4 c3 c2 c1 c4 c3 c2 c1 movx instruction cycle next inst. read next inst. address movx data out movx data address movx inst. address movx inst. c4 c3 c2 c1 c4 c3 c2 c1 figure 9 - 8 : data memory write with stretch value = 2 9.4 wait state control signal either with the software using stretch value to change the required machine cycle of movx instruction, th e n79e352(r) provides another hardware signal wait to implement the wider duration of external data access timing. this wait state control signal is the alternate function of p4.0. the wait state control signal can be enabled by setting ws (sfr rommap.7) bit. when enabled, the setting of stretch value decides the minimum length of movx instruction cycle and the device will sample the wait pin at each c2 state before the rising edge of read/write strobe signal during movx inst ruction. once this signal being recongnized, one more machine cycle (wait state cycle) will be inserted into next cycle. the inserted wait state cycles are unlimited, so the movx instruction cycle will end in which the wait state control signal is deactiva ted. using wait state control signal allows a dynamically access timimg to a selected external peripheral. the ws bit is accessed by the timed access protection procedure.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 67 - revision a0 6 10. power management the n79e352(r) has several features that help the user to control the power consumption of the device. the power saving features are basically the power down mode, economy mode and the idle mode of operation. 10.1 idle mode the user can put the device into idle mode by writing 1 to the bit pcon.0. the instruction that sets the idle bit is the last instruction that will be executed before the device goes into idle mode. in the idle mode, the clock to the cpu is halted, but not to the interrupt, timer, watchdog timer and serial port blocks. this forces the cpu state to be fro zen; the program counter, the stack pointer, the program status word, the accumulator and the other registers hold their contents. the port pins hold the logical states they had at the time idle was activated. the idle mode can be terminated in two ways. s ince the interrupt controller is still active, the activation of any enabled interrupt can wake up the processor. this will automatically clear the idle bit, terminate the idle mode, and the interrupt service routine(isr) will be executed. after the isr, e xecution of the program will continue from the instruction which put the device into idle mode. the idle mode can also be exited by activating the reset. the device can be put into reset either by applying a high on the external rst pin, a power on reset c ondition or a watchdog timer reset. the external reset pin has to be held high for at least two machine cycles i.e. 8 clock periods to be recognized as a valid reset. in the reset condition the program counter is reset to 0000h and all the sfrs are set to the reset condition. since the clock is already running there is no delay and execution starts immediately. in the idle mode, the watchdog timer continues to run, and if enabled, a time - out will cause a watchdog timer interrupt which will wake up the devic e. the software must reset the watchdog timer in order to preempt the reset which will occur after 512 clock periods of the time - out. when the n79e352(r) is exiting from an idle mode with a reset, the instruction following the one which put the device into idle mode is not executed. so there is no danger of unexpected writes. 10.2 economy mode the power consumption of microcontroller relates to operating frequency. the n79e352(r) offers a economy mode to reduce the internal clock rate dynamically without externa l components. by default, one machine cycle needs 4 clocks. in economy mode, software can select 4, 64 or 1024 clocks per machine cycle. it keeps the cpu operating at a acceptable speed but eliminates the power consumption. in the idle mode, the clock of t he core logic is stopped, but all clocked peripherals such as watchdog timer are still running at a rate of clock/4. in the economy mode, all clocked peripherals run at the same reduced clocks rate as in core logic. so the economy mode may provide a lower power consumption than idle mode. software invokes the economy mode by setting the appropriate bits in the sfrs. setting the bits cd0(pmr.6), cd1(pmr.7) decides the instruction cycle rate as below: cd1 cd0 clocks/machine cycle 0 x 4 (default) 1 0 64 1 1 1024 the selection of instruction rate is going to take effect after a delay of one instruction cycle. switching to divide by 64 or 1024 mode must first go from divide by 4 mode. this mea ns software can not switch directly between clock/64 and clock/1024 mode. the cpu has to return clock/4 mode first, then go to clock/64 or clock/1024 mode. in economy mode, the serial port can not receive/transmit data correctly because the baud rate is ch anged. in some systems, the external interrupts may require the fastest process such that the
preliminary n 79 e352/n79e352r data sheet - 68 - reducing of operating speed is restricted. in order to solve these dilemmas, the n79e352(r) offers a switchback feature which allows the cpu back to clock/4 mode immediately when triggered by serial operation (uart and i 2 c ) or external interrupts. the switchback feature is enabled by setting the swb bit (pmr.5). a serial port / i2c reception/transmission or qualified external interrupt which is enabled and acknowledg ed without block conditions will cause cpu to return to divide by 4 mode. for the serial port reception, a switchback is generated by a falling edge associated with start bit if the serial port reception is enabled. when a serial port transmission, an inst ruction which writes a byte of data to serial port buffer will cause a switchback to ensure the correct transmission. the switchback feature is unaffected by serial port interrupt flags. similarly for i2c reception/transmission, a switchback is generated w hen a start condition is determined. after a switchback is generated, the software can manually return the cpu to economy mode. note that the modification of clock control bits cd0 and cd1 will be ignored during i2c or serial port transmit/receive when swi tchback is enabled. the watchdog timer reset, power - on/fail reset , software reset, brownout reset or external reset will force the cpu to return to divide by 4 mode. 10.3 power down mode the device can be put into power down mode by writing 1 to bit pcon.1. th e instruction that does this will be the last instruction to be executed before the device goes into power down mode. in the power down mode, all the clocks are stopped and the device comes to a halt. all activity is completely stopped and the power consum ption is reduce d to the lowest possible valu e . in this state the ale and psen pins are pulled low. the port pins output the values held by their respective sfrs. the n79e352(r) will exit the power down mode with a reset or by an external in terrupt pin. an external reset can be used to exit the power down state. the high on rst pin terminates the power down mode, and restarts the clock. the program execution will restart from 0000h. in the power down mode, the clock is stopped, so the watchdo g timer cannot be used to provide the reset to exit power down mode when its clock source is external osc or crystal . the sources that can wake up from the power down mode are external interrupts, keyboard interrupt (kbi), brownout reset (bor), and watchdo g timer interrupt (if wdtck = 0). the n79e352(r) can be woken from the power down mode by forcing an external interrupt pin activated, provided the corresponding interrupt is enabled, while the global enable(ea) bit is set and the external input has been s et to a level detect mode. if these conditions are met, then the low level on the external pin re - starts the oscillator. then device executes the interrupt service routine for the corresponding external interrupt. after the interrupt service routine is com pleted, the program execution returns to the instruction after the one which put the device into power down mode and continues from there.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 69 - revision a0 6 11. reset conditions the user has several hardware related options for placing the n79e352(r) into reset condition. in general, most register bits go to their reset value irrespective of the reset condition, but there are a few flags whose state depends on the source of reset. the user can use these flags to determine the cause of reset using software. 11.1 sources of reset 11.1.1 ext ernal reset the device samples the rst pin every machine cycle during state c4. the rst pin must be held high for at least two machine cycles before the reset circuitry applies an internal reset signal. thus, this reset is a synchronous operation and requi res the clock to be running. the device remains in the reset state as long as rst pin is high and remains high up to two machine cycles after rst is deactivated. then, the device begins program execution at 0000h. there are no flags associated with the ext ernal reset, but, since the other two reset sources do have flags, the external reset is the cause if those flags are clear. 11.1.2 power - on reset (por) when the power supply rises to the configured level, v rst , the device wi ll perform a power on reset and set th e por flag. the software should clear the por flag, or it will be difficult to determine the source of future resets. 11.1.3 brown - out reset (bor) if the power supply falls below brownout voltage of v bov , the device goes into the reset state. when the power supp ly returns to proper levels, the device performs a brownout reset. 11.1.4 watchdog timer reset the watchdog t imer is a free - running timer with programmable time - out intervals. the program must clear the watchdog timer before the time - out interval is reached to r estart the count. if the time - out interval is reached, an interrupt flag is set. 512 clocks later, i f the watchdog r eset is enabled and the watchdog timer has not been cleared, the w atchdog t imer generate s a reset. the reset condition is maintained by the hardware for two machine cycles , and the wtrf bit in wdcon is set. afterwards, the device begin s program execution at 0000h. 11.1.5 software reset n79e352(r) is enhanced by a software reset. this allows the program code to reset the whole system in software appro ach. just writer 1 to sret bit in auxr1.3, a software reset will perform. note that srst require timed access procedure to write. please refer ta register description 11.2 reset state when the device is reset, m ost registers return to their initial state . the watchdog t imer is disabled if the reset source was a power - on reset . t he program counter is set to 0000h , and the stack pointer is reset to 07h. after this, the device remains in the reset state as long as the reset condition s are satisfied .
preliminary n 79 e352/n79e352r data sheet - 70 - r eset does not affect the on - chip ram , however, so ram is preserved as long as vdd remains above approximately 2v, the minimum operating voltage for the ram. if vdd falls below 2v, the ram contents are also lost. in either case, the stack pointer is always reset, so the stack contents are lost. the wdcon sfr bits are set/cleared in reset condition depending on the source of the reset. external reset watchdog reset power on reset wdcon 0xxx0x00b 0xxx010 0b 0 1xx0000b the por bit wdcon.6 is set only by the power on re set. wtrf bit wdcon.2 is set when the watchdog timer causes a reset. a power on reset will also clear this bit. the ewrst bit wdcon .1 is cleared by all reset . this disables the watchdog timer resets. all the bits in this sfr have unr estricted read access. wdrun , por, ewrst, wdif and wdclr require timed access procedure to write. the remaining bits have unrestricted write accesses.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 71 - revision a0 6 12. programmable timers/ counters the n79e352(r) has three 16 - bit programmable timer/counters and one programmable watchdog timer. the watchdog timer is operationally quite different from the other two timers. 12.1 timer/counters 0 & 1 each of these timer/counters has two 8 bit registers which form the 16 bit counting register. for timer/counter 0 they are th0, the upper 8 bits register, and tl0, the lower 8 bit register. similarly timer/counter 1 has two 8 bit registers, th1 and tl1. the two can be configured to operate either as timers, counting machine cycles or as counters counting external inputs. when configured as a "timer", the tim er counts clock cycles. the timer clock can be programmed to be thought of as 1/12 of the system clock or 1/4 of the system clock. in the "counter" mode, the register is incremented on the falling edge of the external input pin, t0 in case of timer 0, and t1 for timer 1. the t0 and t1 inputs are sampled in every machine cycle at c4. if the sampled value is high in one machine cycle and low in the next, then a valid high to low transition on the pin is recognized and the count register is incremented. since it takes two machine cycles to recognize a negative transition on the pin, the maximum rate at which counting will take place is 1/24 of the master clock frequency. in either the "timer" or "counter" mode, the count register will be updated at c3. therefor e, in the "timer" mode, the recognized negative transition on pin t0 and t1 can cause the count register value to be updated only in the machine cycle following the one in which the negative edge was detected. the "timer" or "counter" function is selected by the " c t / " bit in the tmod special function register. each timer/counter has one selection bit for its own; bit 2 of tmod selects the function for timer/counter 0 and bit 6 of tmod selects the function for timer/counter 1. in addition ea ch timer/counter can be set to operate in any one of four possible modes. the mode selection is done by bits m0 and m1 in the tmod sfr. 12.2 time - base selection the n79e352(r) gives the user two modes of operation for the timer. the timers can be programmed to operate like the standard 8051 family, counting at the rate of 1/12 of the clock speed. this will ensure that timing loops on the n79e352(r) and the standard 8051 can be matched. this is the default mode of operation of the n79e352(r) timers. the user also has the option to count in the turbo mode, where the timers will increment at the rate of 1/4 clock speed. this will straight - away increase the counting speed three times. this selection is done by the t0m and t1m bits in ckcon sfr. a reset sets these bit s to 0, and the timers then operate in the standard 8051 mode. the user should set these bits to 1 if the timers are to operate in turbo mode. 12.2.1 mode 0 in mode 0, the timer/counters act as a 8 bit counter with a 5 bit, divide by 32 pre - scale. in this mode we have a 13 bit timer/counter. the 13 bit counter consists of 8 bits of thx and 5 lower bits of tlx. the upper 3 bits of tlx are ignored. the negative edge of the clock increments the count in the tlx register. when the fifth bit in tlx moves from 1 to 0, t hen the count in the thx register is incremented. when the count in thx moves from ffh to 00h, then the overflow flag tfx in tcon sfr is set. the counted input is enabled only if trx is set and either gate = 0 or intx = 1. when c t / is set to 0, then it will count clock cycles, and if c t / is set to 1, then it will count 1 to 0 transitions on t0 (p3.4) for timer 0 and t1 (p3.5) for timer 1. when the 13 bit count reaches 1fffh the next count will cause it to ro ll- over to 0000h. the timer overflow flag tfx of the relevant timer is set and if enabled an interrupts will occur. note that when used as a timer, the time - base may be either clock cycles/12 or clock cycles/4 as selected by the bits txm of the ckcon sfr.
preliminary n 79 e352/n79e352r data sheet - 72 - 1/4 1/12 c/t = tmod.2 (c/t = tmod.6) t0m = ckcon.3 (t1m = ckcon.4) m1,m0 = tmod.1,tmod.0 (m1,m0 = tmod.5,tmod.4) interrupt t0 = p3.4 (t1 = p3.5) th0 (th1) tl0 (tl1) tf0 (tf1) tr0 = tcon.4 (tr1 = tcon.6) gate = tmod.3 (gate = tmod.7) int0 = p3.2 (int1 = p3.3) 7 0 tfx 4 7 0 timer 1 functions are shown in brackets 1 00 0 0 1 01 fcpu figure 12- 1 : timer/counter mode 0 & mode 1
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 73 - revision a0 6 12.2.2 mode 1 mode 1 is similar to mode 0 except that the counting register forms a 16 bit counter, rather than a 13 bit counter. this me ans that all the bits of thx and tlx are used. roll - over occurs when the timer moves from a count of ffffh to 0000h. the timer overflow flag tfx of the relevant timer is set and if enabled an interrupt will occur. the selection of the time - base in the time r mode is similar to that in mode 0. the gate function operates similarly to that in mode 0. 12.2.3 mode 2 in mode 2, the timer/counter is in the auto reload mode. in this mode, tlx acts as a 8 bit count register, while thx holds the reload value. when the tlx re gister overflows from ffh to 00h, the tfx bit in tcon is set and tlx is reloaded with the contents of thx, and the counting process continues from here. the reload operation leaves the contents of the thx register unchanged. counting is enabled by the trx bit and proper setting of gate and intx pins. as in the other two modes 0 and 1 mode 2 allows counting of either clock cycles (clock/12 or clock/4) or pulses on pin tn. 1/4 1/12 c/t = tmod.2 (c/t = tmod.6) t0m = ckcon.3 (t1m = ckcon.4) interrupt t0 = p3.4 (t1 = p3.5) th0 (th1) tl0 (tl1) tf0 (tf1) tr0 = tcon.4 (tr1 = tcon.6) gate = tmod.3 (gate = tmod.7) int0 = p3.2 (int1 = p3.3) 7 0 tfx 4 7 0 timer 1 functions are shown in brackets 1 0 0 1 fcpu figure 12- 2 : timer/counter mode 2 12.2.4 mode 3 mode 3 has different operating methods for the two timer/counters. for timer/counter 1, mode 3 simply freezes the counter. timer/counter 0, however, configures tl0 and th0 as two separate 8 bit count registe rs in this mode. the logic for this mode is shown in the figure. tl0 uses the timer/counter 0 control bits c t / , gate, tr0, int 0 and tf0. the tl0 can be used to count clock cycles (clock/12 or clock/4) or 1 - to - 0 transitions on pin t0 as determined by c/t (tmod.2). th0 is forced as a clock cycle counter (clock/12 or clock/4) and takes over the use of tr1 and tf1 from timer/counter 1. mode 3 is used in cases where an extra 8 bit timer is needed. with timer 0 in mode 3, timer 1 can still be used in modes 0, 1 and 2., but its flexibility is somewhat limited. while its basic functionality is maintained, it no longer has control over its overflow flag tf1 and the enable bit tr1. timer 1 can still be used as a timer/counter and retai ns the use of gate and int1 pin. in this condition it can be turned on and off by switching it out of and into its own mode 3. it can also be used as a baud rate generator for the serial port.
preliminary n 79 e352/n79e352r data sheet - 74 - 1/4 1/12 c/t = tmod.2 t0m = ckcon.3 interrupt t0 = p3.4 th0 tl0 tr0 = tcon.4 gate = tmod.3 int0 = p3.2 7 0 tf0 4 7 0 1 0 0 1 fcpu tr1 = tcon.6 interrupt tf1 figure 12- 3 : timer/counter 0 mode 3 12.3 timer/counter 2 timer/counter 2 is a 16 bit up/down counter which is configured by the t2mod register and controlled by the t2con register. timer/counter 2 is equipped with a capture/reload capability. a s with the timer 0 and timer 1 counters, there exists considerable flexibility in selecting and controlling the clock, and in defining the operating mode. the clock source for timer/counter 2 may be selected for either the external t2 pin (c/t2 = 1) or th e crystal oscillator, which is divided by 12 or 4 (c/t2 = 0). the clock is then enabled when tr2 is a 1, and disabled when tr2 is a 0. 12.3.1 capture mode the capture mode is enabled by setting the cp rl / 2 bit in the t2con register to a 1. in the cap ture mode, timer/counter 2 serves as a 16 bit up counter. when the counter rolls over from ffffh to 0000h, the tf2 bit is set, which will generate an interrupt request. if the exen2 bit is set, then a negative transition of t2ex pin will cause the value i n the tl2 and th2 register to be captured by the rcap2l and rcap2h registers. this action also causes the exf2 bit in t2con to be set, which will also generate an interrupt. setting the t2cr bit (t2mod.3), the n79e352(r) allows hardware to reset timer 2 au tomatically after the value of tl2 and th2 have been captured.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 75 - revision a0 6 1/4 1/12 fcpu t2=p1.0 0 1 0 1 t2ex=p1.1 t2m=ckcon.5 c/ t2 =t2con.1 exf2 timer2 interrupt t2con.6 tr2=t2con.2 exen2=t2con.3 tl2 th2 rcap2l rcap2h tf2 t2con.7 figure 12- 4 : timer 2 16- bit capture mode 12.3.2 auto - reload mode, counting up the auto - reload mode as an up counter is en abled by clearing the cp rl / 2 bit in the t2con register and clearing the dcen bit in t2mod register. in this mode, timer/counter 2 is a 16 bit up counter. when the counter rolls over from ffffh, a reload is generated that causes the contents o f the rcap2l and rcap2h registers to be reloaded into the tl2 and th2 registers. the reload action also sets the tf2 bit. if the exen2 bit is set, then a negative transition of t2ex pin will also cause a reload. this action also sets the exf2 bit in t2con . 1/4 1/12 fcpu t2=p1.0 0 1 0 1 t2ex=p1.1 t2m=ckcon.5 c/ t2 =t2con.1 exf2 timer2 interrupt t2con.6 tr2=t2con.2 exen2=t2con.3 tl2 th2 rcap2l rcap2h tf2 t2con.7 figure 12- 5 : timer 2 16- bit auto - reload mode, counting up 12.3.3 auto - reload mode, counting up/down timer/counter 2 will be in auto - reload mode as an up/down counter if cp rl / 2 bit in t2con is cleared and the dcen bit in t2mod is set. in this mode, timer/counter 2 is an up/down counter whose direction is controlled by the t2ex pin. a 1 on this pin cause the counter to count up. an overflow while counting up will cause the counter to be reloaded with the contents of the capture
preliminary n 79 e352/n79e352r data sheet - 76 - registers. the next down count following the case where the contents of timer/counter equal the capture registers will load an ffffh into timer/counter 2. in either event a reload will set the tf2 bit . a reload will also toggle the exf2 bit. however, the exf2 bit can not generate an interrupt while in this mode. 1/4 1/12 fcpu t2=p1.0 0 1 0 1 t2ex=p1.1 t2m=ckcon.5 c/ t2 =t2con.1 exf2 timer2 interrupt t2con.6 tr2=t2con.2 tl2 th2 rcap2l rcap2h tf2 t2con.7 0ffh 0ffh down counting reload value up counting reload value figure 12- 6 : timer 2 16- bit auto - reload up/down counter 12.3.4 baud rat e0 generator mode the baud rate generator mode is enabled by setting either the rclk or tclk bits in t2con register. while in the baud rate generator mode, timer/counter 2 is a 16 bit counter with auto reload when the count rolls over from ffffh. however, rolling over does not set the tf2 bit. if exen2 bit is set, then a negative transition of the t2ex pin will set exf2 bit in the t2con register and cause an interrupt request. fcpu t2 =p1 .0 0 1 t2 ex =p1 .1 c /t2 =t2 con .1 exf 2 timer 2 interrupt t2 con .6 tr 2 =t2 con .2 exen 2 =t2 con .3 tl 2 th 2 rcap 2 l rcap 2 h timer 2 overflow 1 /2 figure 12- 7 : baud rate generator mode
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 77 - revision a0 6 12.3.5 programmable clock - out timer 2 is equipped with a new clock - out feature which outputs a 50% duty cycle clock on p1.0. it can be invoked as a programmable clock generator. to configure timer 2 with clock - out mode, soft ware must initiate it by setting bit t2oe = 1, c/t2 = 0 and cp/rl = 0. setting bit tr2 will start the timer. this mode is similar to the baud rate generator mode, it will not generate an interrupt while timer 2 overflow. so it is possible to use timer 2 a s a baud rate generator and a clock generator at the same time. the clock - out frequency is determined by the following equation: the clock - out frequency = oscillator frequency / [4 x 65536- (rcap2h, rcap2l) ] fcpu t2 ex =p1 .1 exf 2 timer 2 interrupt t2 con .6 tr 2 =t2 con .2 exen 2 =t2 con .3 tl 2 th 2 rcap 2 l rcap 2 h timer 2 overflow 1 /2 t2 =p1 .0 1 /2 figure 12- 8 : programmable clock - out mode
preliminary n 79 e352/n79e352r data sheet - 78 - 13. nvm memory the n79e352(r) has nvm data memory of 128 bytes for customer? s data store u sed. th e nvm data memory ha s 8 pages area and each page has 16 bytes. 13.1 operation user is requ ired to ena ble ennvm (nvmcon.5) bit for nvm read. this is due to overlapping of nvm data memory and external data memory physical address, the following table is defined. ennvm bit (nvmcon.5) will enable read access to nvm data memory area. ennvm data me mory area 0 enable external ram read/write access by movx 1 enable nvm data memory read access by movx only. if eer or ewr is set and nvm flash erase or write control is busy, to set this bit read nvm data is invalid. table 13- 1 : movx instruction to enable read data memory area definition table the nvm memory can be read/write by customer program to access. read nvm data is by movx a,@dptr/r0/r1 instructions, and w rite data is by sfr of nvmaddr , nvmdat and nvmcon. before write data to nvm memory, the page must be erased by provid ing page address on nvmaddr , which address of on - chip code memory space will decode, then set eer of nvmcon.7. this will automatic ally hold fetch program code and pc counter, and ex ecute page erase. after finished, this bit will be cleared by hardware. the erase time is ~ 5ms. for writing data to nvm memory, user must s et address and data to nvmaddr and nvmdat, then set ewr of nvmcon.6 to initiate nvm data write. the uc will hold pr ogram code and pc counter, and then write data to mapping address . upon write completion, the ewr bit will be cleared by hardware , the uc will continue execute next instruction . the program time is ~50us. nvm data flash memory is permanently operating from 11.059 2 mhz internal clock source. in order to reduce power consumption, the on chip oscillator will only be enabled when during program or erase, through ewr or eer in nvmcon sfr. ewr or eer bits are cleared by hardware after program or erase completed. t he program/erase time is automatically controlled by hardware.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 79 - revision a0 6 11.0592mhz rc osc nvm data memory block ennvm clock source eer ewr erc internal signal figure 13- 1 : nvm control instructions ennvm = 0 ennvm = 1 addr within nvm address ran ge addr out of nvm addre ss range movx a, @dptr (read) ext memory nvm ext memory movx a, @r0 (read) ext memory nvm ext memory [1] movx a, @r1 (read) ext memory nvm ext memory [1] movx @dptr, a (write) ext memory ext memory ext memory movx @r0, a (write) ext memory ext memory [1] ext memory [1] movx @r1, a (write) ext memory ext memory [1] ext memory [1] table 13- 2 : movx read/write access destination note : 1. higher address bytes will come from sfr port 2 values. for security purposes this nvm data flash provide an independent ?lock bit? located in security bits, it is used to pr otect the customer?s data code in nvm . it may be enabled in config1.6 after the programmer finishes the programming and verifies sequence. once this bit is set to logic 0, nvm flash eprom data can not be accessed again by hardware writer mode .
preliminary n 79 e352/n79e352r data sheet - 80 - 14. wa t chdog timer the watchdog timer is a free - running timer which can be programmed by the user to serve as a system monitor, a time - base generator or an event timer. it i s basically a set of dividers that divide the system clock. the divider output is selectable and determines the time - out interval. when the time - out occurs a flag is set, which can cause an interrupt if enabled, and a system reset can also be caused if it is enabled. the interrupt will occur if the individual interrupt enable and the global enable are set. the interrupt and reset functions are independent of each other and may be used separately or together depending on the user?s software. wdif 512 clock delay mux 20khz+/- 100% rc oscillator fcpu wdtck wdrun wd1,wd0 wdclr ewdi ewrst reset interrupt 00 01 10 11 wtrf 15-bits counter time-out selector 5 0 6 8 9 12 13 14 (reset watchdog) (wdcon.1) (wdcon.3) (eie.4) (wdcon.2) (wdcon.0) (wdcon.7) (security bit) (ckcon.7~6) /enable figure 14- 1 : watchdog timer the watchdog timer should first be restarted by using wdclr. this ensures that the timer starts from a known state. the wdclr bit is used to restart the watchdog t imer. this bit is self clearing, i.e. after writing a 1 to this bit the software will automatically clear it. the watchdog timer will now count clock cycles. the time - out interval is selected by the two bits wd1 and wd0 (ckcon.7 and ckcon.6). when the sele cted time - out occurs, the watchdog interrupt flag wdif (wdcon.3) is set. after the time - out has occurred, the watchdog timer waits for an additional 512 clock cycles. if the watchdog reset ewrst (wdcon.1) is enabled, then 512 clocks after the time - out, if there is no wdclr, a system reset due to watchdog timer will occur. this will last for two machine cycles, and the watchdog timer reset flag wtrf (wdcon.2) will be set. this indicates to the software that the watchdog was the cause of the reset. when used as a simple timer, the reset and interrupt functions are disabled. the timer will set the wdif flag each time the timer completes the selected time interval. the wdif flag is polled to detect a time - out and the wdclr allows software to restart the timer. t he watchdog timer can also be used as a very long timer. the interrupt feature is enabled in this case. every time the time - out occurs an interrupt will occur if the global interrupt enable ea is set. the main use of the watchdog timer is as a system monit or. this is important in real - time control applications. in case of some power glitches or electro - magnetic interference, the processor may begin to execute errant code. if this is left unchecked the entire system may crash. using the watchdog timer interr upt during software development will allow the user to select ideal watchdog reset locations. the code is first written without the watchdog interrupt or reset. then the watchdog interrupt is enabled to identify code locations where interrupt occurs. the u ser can now insert instructions to reset the watchdog timer, which will allow the code to run without any watchdog timer interrupts. now the watchdog timer reset is enabled and the watchdog interrupt may be disabled. if any errant code is
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 81 - revision a0 6 executed now, the n the reset watchdog timer instructions will not be executed at the required instants and watchdog reset will occur. the watchdog timer time - out selection will result in different time - out values depending on the clock speed. the reset will occur, when ena bled, 512 clocks a fter the time - out has occurred. wd1 wd0 watchdog interval number of clocks time @ 20 khz 0 0 2 6 64 3.2 ms 0 1 2 9 512 25.6 ms 1 0 2 13 8192 409.6 ms 1 1 2 15 32768 1638.4 ms table 14- 1 : t ime - out values for the watchdog timer. the default watchdog time - out is 2 6 clocks, which is the shortest time - out period. the ewrst, wdif and wdclr bits are protected by the timed access procedure. this prevents software from accidentally enabling or dis abling the watchdog timer. more importantly, it makes it highly improbable that errant code can enable or disable the watchdog timer. the security bit wdtck is located at bit 7 of config0 register. this bit is for user to configure the clock source of watc hdog timer either from the internal rc or from the uc clock.
preliminary n 79 e352/n79e352r data sheet - 82 - 15. uart serial port serial port in the n79e352(r) is a full duplex port. the n79e352(r) provides the user with additional features such as the frame error detection and the automatic address reco gnition. the serial ports are capable of synchronous as well as asynchronous communication. in synchronous mode the n79e352(r) generates the clock and operates in a half duplex mode. in the asynchronous mode, full duplex operation is available. this means that it can simultaneously transmit and receive data. the transmit register and the receive buffer are both addressed as sbuf special function register. however any write to sbuf will be to the transmit register, while a read from sbuf will be from the rec eive buffer register. the serial port can operate in four different modes as described below. 15.1 mode 0 this mode provides synchronous communication with external devices. in this mode serial data is transmitted and received on the rxd line. txd is used to tr ansmit the shift clock. the txd clock is provided by the n79e352(r) whether the device is transmitting or receiving. this mode is therefore a half duplex mode of serial communication. in this mode, 8 bits are transmitted or received per frame. the lsb is t ransmitted/received first. the baud rate is fixed at 1/12 or 1/4 of the oscillator frequency. this baud rate is determined by the sm2 bit (scon.5). when this bit is set to 0, then the serial port runs at 1/12 of the clock. when set to 1, the serial port ru ns at 1/4 of the clock. this additional facility of programmable baud rate in mode 0 is the only difference between the standard 8051 and the n79e352(r) . the functional block diagram is shown below. data enters and leaves the serial port on the rxd line. t he txd line is used to output the shift clock. the shift clock is used to shift data into and out of the n79e352(r) and the device at the other end of the line. any instruction that causes a write to sbuf will start the transmission. the shift clock will b e activated and data will be shifted out on the rxd pin till all 8 bits are transmitted. if sm2 = 1, then the data on rxd will appear 1 clock period before the falling edge of shift clock on txd. the clock on txd then remains low for 2 clock periods, and t hen goes high again. if sm2 = 0, the data on rxd will appear 3 clock periods before the falling edge of shift clock on txd. the clock on txd then remains low for 6 clock periods, and then goes high again. this ensures that at the receiving end the data on rxd line can either be clocked on the rising edge of the shift clock on txd or latched when the txd clock is low.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 83 - revision a0 6 1 / 12 fcpu 0 tx clock rx clock ti ri tx shift rx start rx shift load sbuf shift clock ri ren sm 2 clock sin parout sbuf read sbuf internal data bus serial controllor clock load parin tx start internal data bus sbuf write to sout transmit shift register serial interrupt rxd txd rxd p 3 . 0 alternate input function p 3 . 0 alternate output function p 3 . 1 alternate output function 1 / 4 1 figure 15- 1 : uart serial port mode 0 the ti flag is set high in c1 following the end of transmission of the last bit. the serial port will receive data when ren is 1 and ri is zero. the shift clock (txd) will be activated and the serial port will latch data on the rising edge of shift clock. the external device should therefore present data on the falling edge on the shift clock. this process continues till all the 8 bits have been received. the ri flag is set in c1 following the last rising edge of the shift clock on txd. this will stop reception, till the ri is clear ed by software. 15.2 mode 1 in mode 1, the full duplex asynchronous mode is used. serial communication frames are made up of 10 bits transmitted on txd and received on rxd. the 10 bits consist of a start bit (0), 8 data bits (lsb first), and a stop bit (1). on receive, the stop bit goes into rb8 in the sfr scon. the baud rate in this mode is variable. the serial baud can be programmed to be 1/16 or 1/32 of the timer 1 overflow or 1/16 of timer 2 overflow . since the timer 1 and 2 can be set to different reload va lues, a wide variation in baud rates is possible. transmission begins with a write to sbuf. the serial data is brought out on to txd pin at c1 following the first roll - over of divide by 16 counter. the next bit is placed on txd pin at c1 following the next rollover of the divide by 16 counter. thus the transmission is synchronized to the divide by 16 counter and not directly to the write to sbuf signal. after all 8 bits of data are transmitted, the stop bit is transmitted. the ti flag is set in the c1 state after the stop bit has been put out on txd pin. this will be at the 10th rollover of the divide by 16 counter after a write to sbuf. reception is enabled only if ren is high. the serial port actually starts the receiving of serial data, with the detection of a falling edge on the rxd pin. the 1 - to - 0 detector continuously monitors the rxd line, sampling it at the rate of 16 times the selected baud rate. when a falling edge is detected, the divide by 16 counter is immediately reset. this helps to align the b it boundaries with the rollovers of the divide by 16 counter.
preliminary n 79 e352/n79e352r data sheet - 84 - the 16 states of the counter effectively divide the bit time into 16 slices. the bit detection is done on a best of three basis. the bit detector samples the rxd pin, at the 8th, 9th and 10th co unter states. by using a majority 2 of 3 voting system, the bit value is selected. this is done to improve the noise rejection feature of the serial port. if the first bit detected after the falling edge of rxd pin is not 0, then this indicates an invalid start bit, and the reception is immediately aborted. the serial port again looks for a falling edge in the rxd line. if a valid start bit is detected, then the rest of the bits are also detected and shifted into the sbuf. after shifting in 8 data bits, th ere is one more shift to do, after which the sbuf and rb8 are loaded and ri is set. however certain conditions must be met before the loading and setting of ri can be done. 1. ri must be 0 and 2. either sm2 = 0, or the received stop bit = 1. if these con ditions are met, then the stop bit goes to rb8, the 8 data bits go into sbuf and ri is set. otherwise the received frame may be lost. after the middle of the stop bit, the receiver goes back to looking for a 1 - to - 0 transition on the rxd pin. 1 / 2 1 / 16 tx clock rx clock ti ri tx shift rx start rx shift load sbuf smod clock sin d 8 sbuf read sbuf internal data bus serial controllor clock load parin tx start internal data bus write to sbuf sout transmit shift register serial interrupt txd rxd parout rb 8 start stop 0 1 bit detector 1 - to - 0 detector sample 1 / 16 0 timer 1 overflow 1 receive shift register 0 1 0 1 tclk rclk timer 2 overflow figure 15- 2 : uart serial port mode 1 15.3 mode 2 this mode uses a total of 11 bits in asynchronous full - duplex communication. the functional description is shown in the figure below. the frame co nsists of one start bit (0), 8 data bits (lsb first), a programmable 9th bit (tb8) and a stop bit (0). the 9th bit received is put into rb8. the baud rate is programmable to 1/32 or 1/64 of the oscillator frequency, which is determined by the smod bit in
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 85 - revision a0 6 p con sfr. transmission begins with a write to sbuf. the serial data is brought out on to txd pin at c1 following the first roll - over of the divide by 16 counter. the next bit is placed on txd pin at c1 following the next rollover of the divide by 16 counter . thus the transmission is synchronized to the divide by 16 counter, and not directly to the write to sbuf signal. after all 9 bits of data are transmitted, the stop bit is transmitted. the ti flag is set in the c1 state after the stop bit has been put out on txd pin. this will be at the 11th rollover of the divide by 16 counter after a write to sbuf. reception is enabled only if ren is high. the serial port actually starts the receiving of serial data, with the detection of a falling edge on the rxd pin. t he 1- to - 0 detector continuously monitors the rxd line, sampling it at the rate of 16 times the selected baud rate. when a falling edge is detected, the divide by 16 counter is immediately reset. this helps to align the bit boundaries with the rollovers of the divide by 16 counter. the 16 states of the counter effectively divide the bit time into 16 slices. the bit detection is done on a best of three basis. the bit detector samples the rxd pin, at the 8th, 9th and 10th counter states. by using a majority 2 of 3 voting system, the bit value is selected. this is done to improve the noise rejection feature of the serial port. tx clock rx clock ti ri tx shift rx start rx shift load sbuf clock sin d 8 sbuf read sbuf internal data bus serial controllor clock load parin tx start internal data bus write to sbuf sout transmit shift register serial interrupt txd rxd parout rb 8 start stop bit detector 1 - to - 0 detector d 8 tb 8 receive shift register 1 / 2 1 / 16 smod sample 1 / 16 0 fcpu / 2 1 figure 15- 3 : uart serial port mode 2 if the first bit det ected after the falling edge of rxd pin, is not 0, then this indicates an invalid start bit, and the reception is immediately aborted. the serial port again looks for a falling edge in the rxd line. if a valid start bit is detected, then the rest of the bi ts are also detected and shifted into the sbuf. after shifting in 9 data bits, there is one more shift to do, after which the sbuf and rb8 are loaded and ri is set. however certain conditions must be met before the loading and setting of ri can be done. 1. ri must be 0 and 2. either sm2 = 0, or the received stop bit = 1.
preliminary n 79 e352/n79e352r data sheet - 86 - if these conditions are met, then the stop bit goes to rb8, the 8 data bits go into sbuf and ri is set. otherwise the received frame may be lost. after the middle of the stop bit, the recei ver goes back to looking for a 1 - to - 0 transition on the rxd pin.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 87 - revision a0 6 15.4 mode 3 this mode is similar to mode 2 in all respects, except that the baud rate is programmable. the user must first initialize the serial related sfr scon before any communication can take place. this involves selection of the mode and baud rate. the timer 1 should also be initialized if modes 1 and 3 are used. in all four modes, transmission is started by any instruction that uses sbuf as a destination register. reception is initiated in m ode 0 by the condition ri = 0 and ren = 1. this will generate a clock on the txd pin and shift in 8 bits on the rxd pin. reception is initiated in the other modes by the incoming start bit if ren = 1. the external device will start the communication by tra nsmitting the start bit. tx clock rx clock ti ri tx shift rx start rx shift load sbuf clock sin d 8 sbuf read sbuf internal data bus serial controllor clock load parin tx start internal data bus write to sbuf sout transmit shift register serial interrupt txd rxd parout rb 8 start stop 0 1 bit detector 1 - to - 0 detector d 8 tb 8 receive shift register 1 / 2 1 / 16 smod sample 1 / 16 0 timer 1 overflow 1 0 1 0 1 tclk rclk timer 2 overflow figure 15- 4 : uart serial port mode 3 sm1 sm0 mode type baud clock frame size start bit stop bit 9th bit function 0 0 0 synch. 4 or 12 t clks 8 bits no n o none 0 1 1 asynch. timer 1 or 2 10 bits 1 1 none 1 0 2 asynch. 32 or 64 t clks 11 bits 1 1 0, 1 1 1 3 asynch. timer 1 or 2 11 bits 1 1 0, 1 table 15- 1 : uart serial port modes
preliminary n 79 e352/n79e352r data sheet - 88 - 15.5 framing error detection a f rame error occurs when a valid stop bit is not detected. this could indicate incorrect serial data communication. typically the frame error is due to noise and contention on the serial communication line. the n79e352(r) has the facility to detect such fram ing errors and set a flag which can be checked by software. the frame error fe b it is located in scon.7 . this bit is normally used as sm0 in the standard 8051 family. however, in the n79e352(r) it serves a dual function a nd is called sm0/fe . there are actu ally two separate flags, one for sm0 and the other for fe. the flag that is actually accessed as scon.7 is determined by smod0 (pcon.6) bit. when smod0 is set to 1, then the fe flag is indicated in sm0/fe. when smod0 is set to 0, then the sm0 flag is indic ated in sm0/fe. the fe bit is set to 1 by hardware but must be cleared by software. note that smod0 must be 1 while reading or writing to fe . if fe is set, then any following frames received without any error will not clear the fe flag. the clearing has to be done by software. 15.6 multiprocessor communications multiprocessor communications makes use of the 9th data bit in modes 2 and 3. in the n79e352(r) , the ri flag is set only if the received byte corresponds to the given or broadcast address. this hardware f eature eliminates the software overhead required in checking every received address, and greatly simplifies the software programmer task. in the multiprocessor communication mode, the address bytes are distinguished from the data bytes by transmitting the address with the 9th bit set high. when the master processor wants to transmit a block of data to one of the slaves, it first sends out the address of the targeted slave (or slaves). all the slave processors should have their sm2 bit set high when waiting for an address byte. this ensures that they will be interrupted only by the reception of a address byte. the automatic address recognition feature ensures that only the addressed slave will be interrupted. the address comparison is done in hardware not sof tware. the addressed slave clears the sm2 bit, thereby clearing the way to receive data bytes. with sm2 = 0, the slave will be interrupted on the reception of every single complete frame of data. the unaddressed slaves will be unaffected, as they will be s till waiting for their address. in mode 1, the 9th bit is the stop bit, which is 1 in case of a valid frame. if sm2 is 1, then ri is set only if a valid frame is received and the received byte matches the given or broadcast address. the master processor ca n selectively communicate with groups of slaves by using the given address. all the slaves can be addressed together using the broadcast address. the addresses for each slave are defined by the saddr and saden sfrs. the slave address is an 8 - bit value spec ified in the saddr sfr. the saden sfr is actually a mask for the byte value in saddr. if a bit position in saden is 0, then the corresponding bit position in saddr is don't care. only those bit positions in saddr whose corresponding bits in saden are 1 are used to obtain the given address. this gives the user flexibility to address multiple slaves without changing the slave address in saddr.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 89 - revision a0 6 the following example shows how the user can define the given address to address different slaves. slave 1: saddr 1 010 0100 saden 1111 1010 given 1010 0x0x slave 2: saddr 1010 0111 saden 1111 1001 given 1010 0xx1 the given address for slave 1 and 2 differ in the lsb. for slave 1, it is a don't care, while for slave 2 it is 1. thus to communicate only with slave 1, the master must send an address with lsb = 0 (1010 0000). similarly the bit 1 position is 0 for slave 1 and don't care for slave 2. hence to communicate only with slave 2 the master has to transmit an address with bit 1 = 1 (1010 0011). if the master wish es to communicate with both slaves simultaneously, then the address must have bit 0 = 1 and bit 1 = 0. the bit 3 position is don't care for both the slaves. this allows two different addresses to select both slaves (1010 0001 and 1010 0101). the master can communicate with all the slaves simultaneously with the broadcast address. this address is formed from the logical oring of the saddr and saden sfrs. the zeros in the result are defined as don't cares in most cases the broadcast address is ffh. in the pre vious case, the broadcast address is (1111111x) for slave 1 and (11111111) for slave 2. the saddr and saden sfrs are located at address a9h and b9h respectively. on reset, these two sfrs are initialized to 00h. this results in given address and broadcast a ddress being set as xxxx xxxx(i.e. all bits don't care). this effectively removes the multiprocessor communications feature, since any selectivity is disabled.
preliminary n 79 e352/n79e352r data sheet - 90 - 16. i2c serial port the i2c bus uses two wires (sda and scl) to transfer information between devic es connected to the bus. the main features of the bus are: ? bidirectional data transfer between masters and slaves ? multimaster bus (no central master) ? arbitration between simultaneously transmitting masters without corruption of serial data on the bus ? serial clock synchronization allows devices with different bit rates to communicate via one serial bus ? serial clock synchronization can be used as a handshake mechanism to suspend and resume serial transfer ? the i2c bus may be used for test and diagn ostic purposes t buf stop sda scl start t hd; sta t low t hd; dat t high t f t su ; dat repeated start t su ; sta t su ; sto stop t r figure 16- 1 : i2c bus timing the device?s on - chip i 2 c logic provides the serial interface that meet s the i 2 c bus standard mode specification. the i2c logic handle s bytes transfer autonomously. it also keeps track of serial transfers, and a status register ( i2status ) reflects the status of the i 2 c bus. the i2c port, scl and sda are at p 1.2 and p 1.3. when the i/o pins are used as i2c port, user must set the pins to l ogic high in advance. when i2c port is enabled by setting ens to high, the internal states will be controlled by i2con and i2c logic hardware. once a new status code is generated and stored in i2status , the i2c interrupt flag (si) will be set automatically . if both ea and ei2c are also in logic high, the i2c interrupt is requested . the 5 most significant bits of i2status stores the internal state code, the lowest 3 bits are always zero and the content keeps stable until si is cleared by software. 16.1 i 2c bus th e i2c bus is a serial i/o port, which supports all transfer modes from and to the i2c bus. the i2c por t handles byte transfers autonomously. to enable this port, the bit ens i in i2con should be set to '1'. the cpu interfaces to the i2c port through the fol lowing six special function registers: i2con (control register, c 0 h), i2status (status register, b d h), i2dat (data register, bc h) , i2addr (address registers, c1 h) , i2clk (clock rate register beh) and i2timer (timer counter register, bfh) . the h/w interface s to the i2c bus via two pins: sda ( p1.2 , serial data line) and scl (p1.3 , serial clock line). pull up resistor is needed for pin p1.2 and p1.3 for i2c operation as these are 2 open drain pins (on i2c mode) .
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 91 - revision a0 6 16.2 the i2c control registers: the i2c has 1 contro l register (i2con) to control the transmit/receive flow, 1 data register (i2dat) to buffer the tx/rx data, 1 status regist er (i2status) to catch the state of tx/rx, recognizable slave address register for slave mode use and 1 clock rate control block for m aster mode to generate the variable baud rate. 16.2.1 the address registers, i2addr i2c port is equipped with one slave address register . the content s of the register are irrelevant when i2c is in master mode. in the slave mode, the seven most significant bits mu st be loaded with the mcu?s own slave address. t he i2c hardware will react if the contents of i2addr are matched with the received slave address. the i2c ports support the ? general call ? function. if the gc bit is set the i2c port1 hardware will respond to general call address (00h). clear gc bit to disable general call function. when gc bit is set, the i2c is in slave mode, it can be received the general call address by 00h after master send general call address to i2c bus, then it will follow status of gc mode. if it is in master mode, the aa bit must be cleared when it will send general call address of 00h to i2c bus. 16.2.2 the data register, i2dat this register contains a byte of serial data to be transmitted or a byte which has just been received. the cpu can read from or write to this 8 - bit directly addressable sfr while it is not in the process of shifting a byte. this occurs when the bus is in a defined state and the serial interrupt flag (si) is set. data in i2 dat remains stable as long as si bit is set. w hile data is being shifted out, data on the bus is simultaneously being shifted in; i2 dat always contains the last data byte present on the bus. thus, in the event of arbitration lost , the transition from master transmitter to slave receiver is made with t he correct data in i2 dat. i2dat and the acknowledge bit form a 9 - bit shift register, the acknowledge bit is controlled by the hardware and cannot be accessed by the cpu. serial data is shifted through the acknowledge bit into i2dat on the rising edges of s erial clock pulses on the scl line. when a byte has been shifted into i2dat, the serial data is available in i2dat, and the acknowledge bit (ack or nack) is returned by the control logic during the ninth clock pulse. serial data is shifted out from i2dat o n the falling edges of scl clock pulses, and is shifted into i2dat on the rising edges of scl clock pulses. i 2 dat . 7 i 2 dat . 6 i 2 dat . 5 i 2 dat . 4 i 2 dat . 3 i 2 dat . 2 i 2 dat . 1 i 2 dat . 0 i 2 c data register : shifting direction
preliminary n 79 e352/n79e352r data sheet - 92 - 16.2.3 the control register, i2con the cpu can read from and write to this 8 - bit, directly addressable sfr. two bits are affected by hardware: the si bit is set when the i2c hardware requests a serial interrupt, and the sto bit is cleared when a stop condition is present on the bus. the sto bit is also cleared when ens = "0". ens i set to e nable i2c serial function block. whe n ens=1 the i2c serial function enables. the port latches of sda1 and scl1 must be set to logic high. st a i2c start flag. setting sta to logic 1 to enter master mode, the i2c hardware sends a start or r epeat start condition to bus when the bus is free. sto i2c stop flag. in master mode, setting sto to transmit a stop condition to bus then i2c hardware will check the bus condition if a stop condition is detected this flag will be cleared by hardware automatically. in a slave mode, setting sto resets i2c har dware to the defined ? not addressed ? slave mode. this means it is no longer in the slave receiver mode to receive data from the master transmit device. si i2c port 1 interrupt flag. when a new i2c bus state is present in the s1sta register, the si flag is set by hardware, and if the ea and ei2c1 bits are both set, the i2c1 interrupt is requested. si must be cleared by software. aa assert acknowledge control bit . when aa=1 prior to address or data received, an acknowledge d ( low level to sda) will be returned during the acknowledge clock pulse on the scl line when 1.) a slave is acknowledging the address sent from master, 2.) the receiver devices are acknowledging the data sent by transmitter. when aa=0 prior to address or data received, a not acknowledged (hi gh level to sda) will be returned during the acknowledge clock pulse on the scl line. 16.2.4 the status register, i2status i2status is an 8 - bit read - only register. the three least significant bits are always 0. the five most significant bits contain the status code. there are 2 6 possible status codes. when i2status contains f8h, no serial interrupt is requested. all other i2status values correspond to defined i2c bus states. when each of these states is entered, a status interrupt is requested (si = 1). a valid status code is present in i2status one machine cycle after si is set by hardware and is still present one machine cycle after si has been reset by software. 16.2.5 the i2c clock baud rate bits, i2clk the data baud rate of i2c is determines by i2clk register when i2c is in a master mode. it is not important when i2c is in a slave mode. in the slave modes, i2c will automatically synchronize with any clock frequency up to 400 khz from master i2c device. the data baud rate of i2c setting is data baud rate of i2c = f cpu / (i2clk+1). the fcpu=fosc/4. if fosc = 16mhz, the i2clk = 40(28h), so data baud rate of i2c = 16mhz/(4x (40 +1)) = 97.56kbits/sec. the block diagram is as below figure.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 93 - revision a0 6 16.2.6 i2c time - out counter, i2timerx t he i2c logic block provides a 14 - bit timer - out counter that helps user to deal with bus pending problem. when si is cleared user can set enti=1 to start the time - out counter. if i2c bus is pended too long to get any valid signal from devices on bus, the time - out counter overflows cause tif=1 to reques t an i2c interrupt. the i2c interrupt is requested in the condition of either si=1 or tif=1. flags si and tif must be cleared by software. 1 0 fcpu 1/4 14-bits counter tif clear counter enti si div4 ens1 to i2c interrupt enable si figure 16- 2 : i2c timer count block diag ram 16.3 modes of operation the on - chip i2c ports support five operation modes, master transmitter , master receiver, slave transmitter , slave receiver , and gc call . in a given application, i2c port may operate as a master or as a slave. in the slave mode, the i2c port hardware looks for its own slave address and the general call address. if one of these addresses is detected, and if the slave is willing to receive or transmit data from/to master(by setting the aa bit), acknowledge pulse will be transmitted out on the 9 th clock, hence an interrupt is requested on both master and slave devices if interrupt is enabled. when the microcontroller wishes to become the bus master, the hardware waits until the bus is free before the master mode is entered so that a poss ible slave action is not interrupted. if bus arbitration is lost in the master mode, i2c port switches to the slave mode immediately and can detect its own slave address in the same serial transfer. 16.3.1 master transmitter mode serial data output through sda wh ile scl outputs the serial clock. the first byte transmitted contains the slave address of the receiving device (7 bits) and the data direction bit. in this case the data direction bit (r/w) will be logic 0, and it is represented by ?w? in the flow diagram s. thus the first byte transmitted is sla+w. serial data is transmitted 8 bits at a time. after each byte is transmitted, an acknowledge bit is received. start and stop conditions are output to indicate the beginning and the end of a serial transfer. 16.3.2 maste r receiver mode in this case the data direction bit (r/w) will be logic 1, and it is represented by ?r? in the flow diagrams. thus the first byte transmitted is sla+r. serial data is received via sda while scl outputs the serial clock. serial data is recei ved 8 bits at a time. after each byte is received, an acknowledge bit is transmitted. start and stop conditions are output to indicate the beginning and end of a serial transfer.
preliminary n 79 e352/n79e352r data sheet - 94 - 16.3.3 slave receiver mode serial data and the serial clock are received through sda and scl. after each byte is received, an acknowledge bit is transmitted. start and stop conditions are recognized as the beginning and end of a serial transfer. address recognition is performed by hardware after reception of the slave address and directio n bit. 16.3.4 slave transmitter mode the first byte is received and handled as in the slave receiver mode. however, in this mode, the direction bit will indicate that the transfer direction is reversed. serial data is transmitted via sda while the serial clock is input through scl. start and stop conditions are recognized as the beginning and end of a serial transfer. 16.4 data transfer flow in f ive operating modes the five operating modes are: master/transmitter, master/receiver, slave/transmitter, slave/receiver and gc call. bits sta, sto and aa in i2con register will determine the next state of the i2c hardware after si flag is cleared. upon complexion of the new action, a new status code will be updated and the si flag will be set. if the i2c interrupt control bits (ea and ei2) are enable, appropriate action or software branch of the new status code can be performed in the interrupt service routine. data transfers in each mode are shown in the following figures. *** legend for the following five figures: 08h a start has been transmitted. (sta,sto,si,aa)=(0,0,0,x) sla+w will be transmitted; ack bit will be received. 18h sla+w has been transmitted; ack has been received. last state last action is done next setting in s1con expected next action next action is done new state software's access to s1dat with respect to "expected next action": software should load the data byte (to be transmitted) into s1dat before new s1con setting is done. (1) data byte will be transmitted: (2) sla+w (r) will be transmitted: software should load the sla+w/r (to be transmitted) into s1dat before new s1con setting is done. (3) data byte will be received: software can read the received data byte from s1dat while a new state is entered. figure 16- 3 : legen for the following four figures
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 95 - revision a0 6 08h a start has been transmitted. (sta,sto,si, aa)=(0, 0,0, x) sla+w will be transmitted; ack bit will be received. set sta to generate a start. 18h sla+w will be transmitted; ack bit will be received. or 20h sla+w will be transmitted; not ack bit will be received. (sta,sto,si,aa)=(1,0,0,x) a repeated start will be transmitted; (sta,sto,si,aa)=(0,0,0,x) data byte will be transmitted; ack will be received. (sta,sto,si ,aa)=(0 ,1,0 ,x) a stop will be transmitted; sto flag will be reset. send a stop (sta,sto,si ,aa)=(1 ,1,0 ,x) a stop followed by a start will be transmitted; sto flag will be reset. send a stop followed by a start 28h data byte in s1dat has been transmitted; ack has been received. or 30h data byte in s1dat has been transmitted; not ack has been received. 10h a repeated start has been transmitted. (sta,sto,si, aa)=(0,0,0, x) sla+r will be transmitted; ack bit will be transmitted; sio1 will be switched to mst/rec mode. 38h arbitration lost in sla+r/w or data byte. (sta,sto,si,aa)=(0,0, 0,x) i2c bus will be release; not address slv mode will be entered. (sta,sto,si, aa)=(1,0,0,x) a start will be transmitted when the bus becomes free. send a start when bus becomes free enter naslave from slave mode (c) to master/receiver (a) from master/receiver (b ) figure 16- 4 : master transmitter mode
preliminary n 79 e352/n79e352r data sheet - 96 - 08h a start has been transmitted. (sta,sto ,si, aa)=(0, 0,0, x) sla+r will be transmitted; ack bit will be received. set sta to generate a start. 40h sla+r has been transmitted; ack has been received. (sta,sto,si, aa)=(0,1,0 ,x) a stop will be transmitted; sto flag will be reset. (sta,sto,si,aa)=(1,1,0 ,x) a stop followed by a start will be transmitted; sto flag will be reset. (sta,sto,si,aa)=(0,0,0,0) data byte will be received; not ack will be returned. send a stop (sta,sto,si, aa)=(0,0,0 ,1) data byte will be received; ack will be returned. 10h a repeated start has been transmitted. (sta,sto,si,aa)=(0,0,0,x) sla+r will be transmitted; ack bit will be transmitted; sio1 will be switched to mst/rec mode. (sta,sto,si,aa)=(1, 0,0,x) a start will be transmitted; when the bus becomes free (sta,sto,si,aa)=(0,0,0,x) i2c bus will be release; not address slv mode will be entered. enter naslave from master/transmitter (a) to master/transmitter (b) from slave mode (c) 48h sla+r has been transmitted; not ack has been received. 58h data byte has been received; not ack has been returned. 50h data byte has been received; ack has been returned. send a stop followed by a start 38h arbitration lost in not ack bit. send a start when bus becomes free (sta,sto,si,aa )=(1,0,0, x) a repeated start will be transmitted; figure 16- 5 : master receiver mode
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 97 - revision a0 6 set aa a8h own sla+r has been received; ack has been return. or b0h arbitration lost sla+r/w as master; own sla+r has been received; ack has been return. (sta,sto,si,aa)=(1,0,0,1) switch to not address slv mode; own sla will be recognized; a start will be transmitted when the bus becomes free. (sta,sto,si,aa)=(0,0,0,0) last data will be transmitted; ack will be received. (sta,sto,si,aa)=(0,0,0,1) data byte will be transmitted; ack will be received. send a start when bus becomes free c8h last data byte in s1dat has been transmitted; ack has been received. (sta,sto,si,aa)=(1,0,0,0) switch to not addressed slv mode; no recognition of own sla; a start will be transmitted when the becomes free. (sta,sto,si,aa)=(0,0,0,1) switch to not addressed slv mode; own sla will be recognized. (sta,sto,si,aa)=(0,0,0,0) switch to not addressed slv mode; no recognition of own sla. enter naslave to master mode (c) (sta,sto,si,aa)=(0,0,0,0) last data byte will be transmitted; ack will be received. (sta,sto,si,aa)=(0,0,0,1) data byte will be transmitted; ack will be received. c0h data byte or last data byte in s1dat has been transmitted; not ack has been received. b8h data byte in s1dat has been transmitted; ack has been received. a0h a stop or repeated start has been received while still addressed as slv/trx. figure 16- 6 : slave transmitter mode
preliminary n 79 e352/n79e352r data sheet - 98 - set aa 60h own sla+w has been received ; ack has been return . or 68h arbitration lost sla+r/ w as master; own sla+w has been received; ack has been return. (sta,sto,si,aa )=(1,0, 0,1) switch to not address slv mode; own sla will be recognized; a start will be transmitted when the bus becomes free. (sta,sto,si,aa)=(0 ,0,0,0) data will be received; not ack will be returned. (sta,sto,si, aa)=(0,0,0,1) data will be received; ack will be returned. send a start when bus becomes free 88h previously addressed with own sla address; not ack has been returned. (sta,sto,si,aa)=(1,0,0,0) switch to not addressed slv mode; no recognition of own sla; a start will be transmitted when the becomes free. (sta,sto,si, aa)=(0, 0,0,1) switch to not addressed slv mode; own sla will be recognized. (sta,sto,si,aa)=(0,0,0,0) switch to not addressed slv mode; no recognition of own sla. enter naslave to master mode (c) (sta ,sto, si,aa)=( 0,0,0 ,0) data byte will be received; not ack will be returned. (sta,sto,si,aa)=(0,0,0 ,1) data byte will be received; ack will be returned. 80h previously addressed with own sla address; data has been received; ack has been returned. a0h a stop or repeated start has been received while still addressed as slv/rec. figure 16- 7 : slave receiver mode
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 99 - revision a0 6 set aa 70h reception of the general call address and one or more data bytes; ack has been return. or 78h arbitration lost sla+r/w as master; and address as sla by general call; ack has been return. (sta,sto ,si,aa)=(1,0,0,1) switch to not address slv mode; own sla will be recognized; a start will be transmitted when the bus becomes free. (sta,sto,si, aa)=(x, 0,0, 0) data will be received; not ack will be returned. (sta,sto,si,aa)=(x,0 ,0,1) data will be received; ack will be returned. send a start when bus becomes free 98h previously addressed with general call; data byte has been received; not ack has been returned. (sta,sto,si,aa)=(1 ,0,0,0) switch to not addressed slv mode; no recognition of own sla; a start will be transmitted when the becomes free. (sta,sto, si,aa)=( 0,0,0,1) switch to not addressed slv mode; own sla will be recognized. (sta,sto,si,aa)=(0,0 ,0,0) switch to not addressed slv mode; no recognition of own sla. enter naslave to master mode (c) (sta,sto,si,aa)=(x,0,0,0) data byte will be received; not ack will be returned. (sta ,sto, si,aa )=(x, 0,0,1) data byte will be received; ack will be returned. 90h previously addressed with general call; data has been received; ack has been returned. a0h a stop or repeated start has been received while still addressed as slv/rec. figure 16- 8 : gc mode
preliminary n 79 e352/n79e352r data sheet - 100 - 17. timed access protect ion the n79e352(r) has several new features, like the watchdog timer, on- chip rom size adjustment, wait state control signal and power on/fail reset flag, which are crucial to proper operation of the system. if left unprotected, errant code may write to the watchdog control bits resulting in incorrect operation and loss of c ontrol. in order to prevent this, the n79e352(r) has a protection scheme which controls the write access to critical bits. this protection scheme is done using a timed access. in this method, the bits which are to be protected have a timed write enable win dow. a write is successful only if this window is active, otherwise the write will be discarded. this write enable window is open for 3 machine cycles if certain conditions are met. after 3 machine cycles, this window automatically closes. the window is op ened by writing aah and immediately 55h to the timed access(ta) sfr. this sfr is located at address c7h. the suggested code for opening the timed access window is ta reg 0c7h ; define new register ta, located at 0c7h mov ta, #0aah mov ta, #055h when th e software writes aah to the ta sfr, a counter is started. this counter waits for 3 machine cycles looking for a write of 55h to ta. if the second write (55h) occurs within 3 machine cycles of the first write (aah), then the timed access window is opened. it remains open for 3 machine cycles, during which the user may write to the protected bits. once the window closes the procedure must be repeated to access the other protected bits. examples of timed assessing are shown below example 1: valid access mov ta, #0aah 3 m/c note: m/c = machine cycles mov ta, #055h 3 m/c mov wdcon, #00h 3 m/c example 2: valid access mov ta, #0aah 3 m/c mov ta, #055h 3 m/c nop 1 m/c setb ewrst 2 m/c example 3: valid access mov ta, #0aah 3 m/c mov ta, #055h 3 m/c orl wdcon, #00000010b 3m/c example 4: invalid access mov ta, #0aah 3 m/c mov ta, #055h 3 m/c nop 1 m/c nop 1 m/c clr por 2 m/c example 5: invalid access mov ta, #0aah 3 m/c nop 1 m/c
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 101 - revision a0 6 mov ta, #055h 3 m/c setb ewrst 2 m/c in the first two examples, the writing to the protected bits is done before the 3 machine cycle window closes. in example 3, however, the writing to the protected bit occurs after the window has closed, and so there is effectively no ch ange in the status of the protected bit. in example 4, the second write to ta occurs 4 machine cycles after the first write, therefore the timed access window in not opened at all, and the write to the protected bit fails.
preliminary n 79 e352/n79e352r data sheet - 102 - 18. interrupt s n79e352(r) has four priority level interrupts structure with 1 1 interrupt sources. each of the interrupt sources has an individual priority bit, flag, interrupt vector and enable bit. in addition, the interrupts can be globally enabled or disabled. 18.1 interrupt sources the ext ernal interrupts int0 and int1 can be either edge triggered or level triggered, programmable through bits it0 and it1 (sfr tcon). the bits ie0 and ie1 in tcon register are the flags which are checked to generate the interrupt. in the edge triggered mode, the intx inputs are sampled in every machine cycle. if the sample is high in one cycle and low in the next, then a high to low transition is detected and the interrupts request flag iex in tcon is set. the flag bit requests the int errupt. since the external interrupts are sampled every machine cycle, they have to be held high or low for at least one complete machine cycle. the ie x flag is automatically cleared when the service routine is called. if the level triggered mode is select ed, then the requesting source has to hold the pin low till the interrupt is serviced. the ie x flag will not be cleared by the hardware on entering the service routine. if the interrupt continues to be held low even after the service routine is completed, then the processor may acknowledge another interrupt request from the same source. the timer 0 and 1 interrupts are generated by the tf0 and tf1 flags. these flags are set by the overflow in the timer 0 and timer 1. the tf0 and tf1 flags are automatically cleared by the hardware when the timer interrupt is serviced. the watchdog timer can be used as a system monitor or a simple timer. in either case, when the time - out count is reached, the watchdog timer interrupt flag wdif (wdcon.3) is set. if the interrup t is enabled by the enable bit eie.4, then an interrupt will occur. the timer 2 interrupt is generated through tf2 (timer 2 overflow/compare match). the hardware does not clear these flags when a timer 2 interrupt is executed. the uart serial block can gen erate interrupt on reception or transmission. there are two i nterrupt sources from the uart block, which are obtained by the ri and ti bits in the scon sfr. these bits are not automatically cleared by the hardware, and the user will have to clear these bit s using software. this device also provide an independent i2c serial port. when new i2c state is present in i2status, the si flag is set by hardware, and if ea and e i2 bits are both set, the i2c interrupt is requested. si must be cleared by software. keybo ard interrupt is generated when any of the keypad connected to p0 pins is pressed. each keypad interrupt can be individually enabled or disabled. user will have to software clear the flag bit. the input capture 0 interrupt is generated through cptf0 flag . cptf0 flag is set by input capture events. the har dware does not clear this flag when the capture interrupt is executed. software has to clear the flag. brownout detect can cause brownout flag, bof, to be asserted if power voltage drop below brownout volt age level. interrupt will occur if boi (auxr1.5), ebo ( eie.6 ) and global interrupt enable are set. source vector address source vector address external interrupt 0 0003h timer 0 overflow 000b h external interrupt 1 0013h timer 1 overflow 001b h serial por t 0023h brownout interrupt 002b h i2c interrupt 0033h kbi interrupt 003b h timer 2 overflow 0043h - 004b h watchdog timer 0053h - 005b h
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 103 - revision a0 6 0063h input capture 0 interrupt 006bh table 18 - 1 : n79e352 (r) interrupt vector table 18.2 pri ority level structure there are four priority levels for the interrupts, highest, high, low and lowest. the interrupt sources can be individually set to either high or low levels. naturally, a higher priority interrupt cannot be interrupted by a lower prio rity interrupt. however there exists a pre - defined hierarchy amongst the interrupts themselves. this hierarchy comes into play when the interrupt controller has to resolve simultaneous requests having the same priority level. this hierarchy is defined as s hown on table 18 - 2 : four - level interrupts priority . the interrupt flags are sampled every machine cycle. in the same machine cycle, the sampled interrupts are polled and their priority is resolved. if certain cond itions are met then the hardware will execute an internally generated lcall instruction which will vector the process to the appropriate interrupt vector address. the conditions for generating the lcall are; 1. an interrupt of equal or higher priority is n ot currently being serviced. 2. the current polling cycle is the last machine cycle of the instruction currently being execute. 3. the current instruction does not involve a write to ie, eie, ip0, ip0h, ip1 or iph1 registers and is not a reti. if any of th ese conditions are not met, then the lcall will not be generated. the polling cycle is repeated every machine cycle, with the interrupts sampled in the same machine cycle. if an interrupt flag is active in one cycle but not responded to, and is not active when the above conditions are met, the denied interrupt will not be serviced. this means that active interrupts are not remembered; every polling cycle is new. the processor responds to a valid interrupt by executing an lcall instruction to the appropriate service routine. this may or may not clear the flag which caused the interrupt. in case of timer interrupts, the tf0 or tf1 flags are cleared by hardware whenever the processor vectors to the appropriate timer service routine. in case of external interrup t, /int0 and /int1, the flags are cleared only if they are edge triggered. in case of serial interrupts, the flags are not cleared by hardware. in the case of timer 2 interrupt, the flags are not cleared by hardware. the watchdog timer interrupt flag wdif has to be cleared by software. the hardware lcall behaves exactly like the software lcall instruction. this instruction saves the program counter contents onto the stack, but does not save the program status word psw. the pc is reloaded with the vector add ress of that interrupt which caused the lcall. these address of vector for the different sources are as shown on table 18 - 3 : summary of interrupt sources . the vector table is not evenly spaced; this is to accommod ate future expansions to the device family. execution continues from the vectored address till an reti instruction is executed. on execution of the reti instruction the processor pops the stack and loads the pc with the contents at the top of the stack. th e user must take care that the status of the stack is restored to what it was after the hardware lcall, if the execution is to return to the interrupted program. the processor does not notice anything if the stack contents are modified and will proceed wit h execution from the address put back into pc. note that a ret instruction would perform exactly the same process as a reti instruction, but it would not inform the interrupt controller that the interrupt service routine is completed, and would leave the c ontroller still thinking that the service routine is underway. n79e352(r) use s a four priority level interrupt structure. this allows great flexibility in controlling the handling of the interrupt sources.
preliminary n 79 e352/n79e352r data sheet - 104 - priority bits interrupt priority l evel ip x h ip x 0 0 level 0 (lowest priority) 0 1 level 1 1 0 level 2 1 1 level 3 (highest priority) table 18 - 2 : four - level interrupts priority each interrupt source can be individually enabled or disabled by setting or clearing a bi t in registers ie or eie. the ie register also contains a global disable bit, ea, which disables all interrupts at once. each interrupt source can be individually programmed to one of four priority levels by setting or clearing bits in the ip0, ip0h, ip1, and ip1h registers. an interrupt service routine in progress can be interrupted by a higher priority interrupt, but not by another interrupt of the same or lower priority. the highest priority interrupt service cannot be interrupted by any other interrupt source. so, if two requests of different priority levels are received simultaneously, the request of higher priority level is serviced. if requests of the same priority level are received simultaneously, an internal polling sequence determines which reque st is serviced. this is called the arbitration ranking. note that the arbitration ranking is only used to resolve simultaneous requests of the same priority level. table below summarizes the interrupt sources, flag bits, vector address, enable bits, priori ty bits, arbitration ranking, and whether each interrupt may wake up the cpu from power down mode. source flag vector address enable bit flag cleared by priority bit arbitration ranking power - down wakeup external interrupt 0 ie0 0003h ex0 (ie.0) hardware , software ip0h.0, ip0.0 1(highest) yes brownout detect bof 002bh ebo ( eie.6 ) hardware ip1h.6, ip1.6 2 yes watchdog timer wdif 0053h ewdi (eie.4) software ip1h.4, ip1.4 3 yes timer 0 overflow tf0 000bh et0 (ie.1) hardware, software ip0h.1, ip0.1 4 no i 2c interrupt si + tif 0033h ei2 (eie.0) software ip1h.0, ip1.0 5 no external interrupt 1 ie1 0013h ex1 (ie.2) hardware, software ip0h.2, ip0.2 6 yes kbi kbf 003bh ekb (eie.1) software ip1h.1, ip1.1 7 yes timer 1 overflow tf1 001bh et1 (ie.3) hardware, s oftware ip0h.3, ip0.3 8 no u art ri + ti 0023h es (ie.4) s oftware ip0h.4, ip0.4 9 no
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 105 - revision a0 6 timer 2 overflow/ match tf2 + exf2 0043h et2 (ie .5 ) s oftware ip0h.5, ip0 . 5 10 no input capture cptf0 006bh ecptf (eie.7) software ip1h.7, ip1.7 11 no table 18 - 3 : summary of interrupt sources note: 1. the watchdog timer can wake up power down mode when its clock source is used internal rc. 18.3 interrupt response time the response time for each interrupt source depends on several factors, such as the nature of the interrupt and the instruction underway. in the case of external interrupts int0 to int1 , they are sampled at c3 of every machine cycle and then their corresponding interrupt flags iex will be set or reset. the ti mer 0 and 1 overflow flags are set at c3 of the machine cycle in which overflow has occurred. these flag values are polled only in the next machine cycle. if a request is active and all three conditions are met, then the hardware generated lcall is execute d. this lcall itself takes four machine cycles to be completed. thus there is a minimum time of five machine cycles between the interrupt flag being set and the interrupt service routine being executed. a longer response time should be anticipated if any o f the three conditions are not met. if a higher or equal priority is being serviced, then the interrupt latency time obviously depends on the nature of the service routine currently being executed. if the polling cycle is not the last machine cycle of the instruction being executed, then an additional delay is introduced. the maximum response time (if no other interrupt is in service) occurs if the device is performing a write to ie, eie, ip0, ip0h, ip1 or ip1h and then executes a mul or div instruction. fr om the time an interrupt source is activated, the longest reaction time is 12 machine cycles. this includes 1 machine cycle to detect the interrupt, 2 machine cycles to complete the ie, eie, ip0, ip0h, ip1 or ip1h access, 5 machine cycles to complete the m ul or div instruction and 4 machine cycles to complete the hardware lcall to the interrupt vector location. thus in a single - interrupt system the interrupt response time will always be more than 5 machine cycles and not more than 12 machine cycles. the max imum latency of 12 machine cycle is 48 clock cycles. note that in the standard 8051 the maximum latency is 8 machine cycles which equals 96 machine cycles. this is a 50% reduction in terms of clock periods. 18.4 interrupt inputs n79e352(r) has two individual i nterrupt inputs as well as the keyboard interrupt function. the latter is described separately elsewhere in this section. two interrupt inputs are identical to those present on the standard 80c51 microcontroller. the external sources can be programmed to b e level - activated or transition - activated by setting or clearing bit it1 or it0 in register tcon. if itn = 0, external interrupt n is triggered by a detected low at the intn pin. if itn = 1, external interrupt n is edge triggered. in this mode if successiv e samples of the /intn pin show a high in one cycle and a low in the next cycle, interrupt request flag ien in tcon is set, causing an interrupt request. since the external interrupt pins are sampled once each machine cycle, an input high or low should h old for at least 6 cpu clocks to ensure proper sampling. if the external interrupt is high for at least one machine cycle, and then hold it low for at least one machine cycle. this is to ensure that the
preliminary n 79 e352/n79e352r data sheet - 106 - transition is seen and that interrupt request flag ie n is set. ien is automatically cleared by the cpu when the service routine is called. if the external interrupt is level - activated, the external source must hold the request active until the requested interrupt is actually generated. if the external interr upt is still asserted when the interrupt service routine is completed another interrupt will be generated. it is not necessary to clear the interrupt flag ien when the interrupt is level sensitive, it simply tracks the input pin level. if an external inter rupt is enabled when the device is put into power down or idle mode, the interrupt will cause the processor to wake up and resume operation. refer to the section on power management for details. ei2 es ri + ti et1 tf1 et0 tf0 ea ie0 ie1 bof kbf wdif ewdi ekb ebo ex1 ex0 interrupt to cpu wakeup (if in power down) et2 tf2 ecptf cptf0 si figure 18 - 1 : interrupt inputs 19. keyboard function the n79e352(r) provided s 8 keyboard interrupt function to detect keypad status which key is acted, and allow a single interrupt to be generated when any key is pressed on a keyboard or keypad
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 107 - revision a0 6 connected to s pecific pins of the n79e352(r ) , as shown below f igure. this interrupt may be used to wake up the cpu from idle or power down modes , after chip is in power down or idle mode . keyboard function is support ed through by port 0. it can allow any or all pins o f p ort 0 to be enabled to cause this interrupt. port pins are enabled by the setting of bits of kbi0 ~ kbi7 in th e kbi register, as shown below f igure. the keyboard interrupt flag (kbf) in the auxr1 register is set wh en any enabled pin is triggered while t he kbi interrupt function is active , and the low pulse must be more than 1 machine cycle, a n interrupt will be generated if it has been enabled. t he kbf bit set by hardware and must be cleared by software. in order to determine which key was pressed, t he k bi will allow the interrupt service routine to poll port 0. the n79e352(r) has addition sfr kbl level configuration register to control either a low or high level trigger. p0.7 kbi.0 kbi.1 kbi.2 kbi.3 kbi.4 kbi.5 kbi.6 kbi.7 ekb (from eie register) kbf (kbi interrupt) high/low level kbl.7 p0.6 high/low level kbl.6 p0.5 high/low level kbl.5 p0.4 high/low level kbl.4 p0.3 high/low level kbl.3 p0.2 high/low level kbl.2 p0.1 high/low level kbl.1 p0.0 high/low level kbl.0 figure 19- 1 : kbi inputs
preliminary n 79 e352/n79e352r data sheet - 108 - 20. input capture the input capture mod ules are function to detect/ measure pulse width and period of a square wave. it supports one capture inputt with digital noise rejection filter. the modules are configur ed by capcon0, capcon1 and t2mo d sfr reg isters. input capture has its own ed ge detector but share with timer 0 . the input capture is a s chmitt trigger pin . for this operation it basically consists of; ? c apture mod ule function block ? timer 0 (mode 0 and 1) block the capture module block c onsists of 2 bytes capture registers, noise filter and programmable edge triggers. noise filter is used to filter the unwanted glitch or pulse on the trigger input pin. the noise filter can be enabled through bit enf0 (capcon1). if enabled, the capture lo gic required to sample 4 consecutive same capture input value in order to recognize an edge as a capture event. a possible implementation of digital noise filter is as follow; q q set clr d q q set clr d q q set clr d q q set clr d j q q k set clr tx filtered clk tx figure 20- 1 : noise filter the interval between pulse s requirement for input capture is 1 machine cycle width, which is the same as the pulse width required to guarantee a trigger for all trigger edge mode. for less than 3 system clocks, anything less than 3 clocks will not have any trigger and pulse width of 3 or more but less than 4 clocks will trigger but will not g u ara n tee 100% because input sampling is at stage c3 of the machine cycle. the trigger optio n is programmable through cct0 [ 1 : 0 ] (capcon0 [3:2] ). it supports positive edge, negative edge and both edge triggers. the c apture module consists of an enable, icen0 (t2mod .4 ) . timer/counter 0 needs to be configured as mode 0 or 1 recommanded . it?s content will transfer to ccl 0 and cch0 sfr when cptf0 is se t. if icen0 is enabled, each time the external pin trigger, the content tl0 and th0 (from timer 0 block) will be captured/transferred into the capture registers, ccl0 and cch0 , depending which external pin trigger. this action also causes the cptf0 flag bi t in capcon1 to be set, which will also generate an interrupt (if ena bled by ecptf bit in sfr eie.7 ). the flag is set by hardware and clear ed by software. setting the t0cc bit (capcon1.6 ), will allow hardware to reset timer 0 auto matically after the value of tl0 and th0 have been captured.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 109 - revision a0 6 noise filter ccl 0 cch 0 capture 0 block [ 00 ] [ 01 ] [ 10 ] t0 (p3.4) capcon0.cct0.1~0 edge select capcon1.enf0 with schmitt trigger cptf0 timer 0 (recommanded mode 0 or 1) capcon1.t0cc (timer 0 count clear enable) t2mod.icen0 figure 20- 2 : input capture block
preliminary n 79 e352/n79e352r data sheet - 110 - 21. pulse width modulate d outputs (pwm) the n79e352(r) contains two pulse width modulated (pwm) channels which generate pulses of programmable length and interval. the output for pwm0 is on p1.4 and pwm1 on p1.5. after chip reset the internal output of the each pwm channel is a ?1? (if prhi=1). the pwm block diagram is shown as below figure. the interval between s uccessive outputs is controlled by a 8 ? bit up - counter which uses the selectable clock sources. the clock sources supported are cpu clock, timer 0 overflow and timer 1 overflow, selectable by pwmcon3.pclk.1~0 bits. the clock sources can be further divided w ith programmable pwmcon3.fp1~0 bits. when the counter reaches overflow, it is reloaded with zero . the width of each pwm output pulse is determined by the value in the appropriate compare registers, pwmnl (n=0,1). when the counter described above matches c ompare register value the pwm output is forced low. it remains low until the counter value overflow. the number of clock pulses that the pwmn output is low is given by: t lo = (ffh ? pwmn+1) p1.4 divider (/1, /2, /4, /8) + - 8-bit up counter pwmrun pwm0l register overflow + - fcpu timer 0 overflow pclk.1~0 0 1 0 1 pwm1oe overflow clrpwm timer 1 overflow reserved 00 01 10 11 fp.1~0 pwm0 (p1.4) p1.5 pwm0oe pwm1 (p1.5) pwm1l register pwm1l buffer pwm0l buffer > > vdd vdd a compare value of all zeroes, 00h, causes the output to remain permanently high. a compare value of all ones, ffh, results in the pwm output remaining permanently low. the overall functioning of the pwm module is controlled by the contents of the pwmcon1 and pwmcon3 registers. the operati on of most of the control bits are straightforward. the transfer compare registers to the buffer registers is controlled by 8 - bit counter overflow, while pwmcon1.7 (pwmrun) allows the pwm to be either in the run or idle state. it has a clrpwm bit to clear 8 - bt up counter. when the pwmrun is cleared, the pwm outputs take on the state they had just prior to the bit being cleared. in general this state is not known. in order to place the outputs in a known state when pwmrun is cleared the compare registers can be written to either the ?all 1? or ?all 0? so the output will have the output desired when the counter is halted. note: during pwm initial run, user is recommended to configure proper pwmn and/or pwm output pin (default high) follow by setting pwmrun a nd clrpwm bits, prior to enable pwmnoe. this is to avoid unexpected pwm output.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 111 - revision a0 6 22. i/o port n79e352(r) has four 8 bits i/o ports; port 0, port 1 , port 2, port 3, one partial port 4; p 4 .0 to p 4 . 3 and one partial port 5; p5.0 to p5.1. a ll pins of i/o ports ( except port4) can be configured to one of four types by software . user may configure the mode type for the above port pin by programming pxmy sfrs. port 4 support only quasi mode. p x m1.y p x m2.y [n ote ] port input/ output mode 0 0 quasi - bidirectional. 0 1 push - pull 1 0 input only (high impedance) ports .pxs=0, ttl input ports .pxs=1, schmitt input 1 1 open drain table 22- 1 : i/o port configuration table note: x = 0 - 3 and 5. y = 0 - 7. in addition, port defau lt mode is also configurable through config0.pmode bit. when pmode = 1, ports 1~3 and 5 will default to quasi mode upon all reset. if pmode = 0, ports 1~3 and 5 will default to open drain mode upon all reset. see table below. ports config0.pmode upon re set pxm1,2 reset value p0 x open drain p0m1,2 = 1111 1111b p1~3 1 quasi p(1~3)m1,2 = 0000 0000b 0 open drain p(1~3)m1,2 = 1111 1111b p4 x quasi not available. p5 [1] 1 quasi p5m1 = xxxx x000b p5m2 = xxxx xx00b 0 open drain p5m1 = xxxx x011b p5m2 = x xxx xx11b table 22- 2 : default port mode configuration by config0.pmode bit. note : 1. product configure d to ru n internal rc . all port pins can be determined to high or low after reset by configure prhi bit i n the config 0 register. besides p4 is permenant schmitt trigger intput, e ach i/o port of n79e352(r) may be selected to use ttl level inputs or schmitt inputs by p(n)s bit on p orts sfr register ; where n is 0, 1 , 2 , 3 or 5 . when p(n)s is set to 1, ports are selected schmitt trigger inputs on port(n). 22.1 quasi - bidirectional output configuration
preliminary n 79 e352/n79e352r data sheet - 112 - the default port output configuration for standard n79e352(r) i/o ports is the quasi - bidirectional output that is common on the 80c51 and most of its derivatives. this output type can be used as both an input and output without the need to reconfigure the port. this is possible because when the port outputs a logic high, it is weakly driven, allowing an external device to pull the pin low. when the pin is pulled low, it is driven strongly and able to sink a fairly large current. these features are somewhat similar to an open drain output except that there are three pull - up transistors in the quasi - bidirectional output that serve different purposes. one of these pull - ups, called the ?very weak? pull - up, is turned on whenever the port latch for the pin contains a logic 1. the very weak pull - up sources a very small current that will pull the pin high if it is left floating. a second pull - up, called the ?weak? pull - up, is turn ed on when the port latch for the pin contains a logic 1 and the pin itself is also at a logic 1 level. this pull - up provides the primary source current for a quasi - bidirectional pin that is outputting a 1. if a pin that has a logic 1 on it is pulled low b y an external device, the weak pull - up turns off, and only the very weak pull - up remains on. in order to pull the pin low under these conditions, the external device has to sink enough current to overpower the weak pull - up and take the voltage on the port pin below its input threshold. the third pull - up is referred to as the ?strong? pull - up. this pull - up is used to speed up low - to - high transitions on a quasi - bidirectional port pin when the port latch changes from a logic 0 to a logic 1. when this occurs, t he strong pull - up turns on for a brief time, two cpu clocks, in order to pull the port pin high quickly. then it turns off again. the quasi - bidirectional port configuration is shown as below. port pin 2 cpu clock delay input data port latch data p p p n vdd strong very weak weak figure 22- 1 : quasi - bidirectional output 22.2 open drain output configuration the open drain output configuration turns off all pull - ups and only drives the pull - down transistor of the port driver when the port latch contains a logic 0. to be used as a logic output, a port configured in this manner must have an external pull - up, typically a resistor tied to v dd . the pull - down for this mode is the same as for the quasi - bidirectional mode. the open drain port configuration is shown as below.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 113 - revision a0 6 port pin port latch data n input data figure 22- 2 : open drain output 22.3 push - pull output configuration the push - pull output configuration has the same pull - down structure as both the open drain and the quasi - bidirectional outpu t modes, but provides a continuous strong pull - up when the port latch contains a logic 1. the push - pull mode may be used when more source current is needed from a port output. the push - pull port configuration is shown below. the value of port pins at rese t is determined by the prhi bit in the config 0 register. ports may be configured to reset high or low as needed for the application. when port pins are driven high at reset, they are in quasi - bidirectional mode and therefore do not source large amounts of current. every output on the device may potentially be used as a 20ma sink led drive output. however, there is a maximum total output current for all ports which must not be exceeded. all ports pins of the device have slew rate controlled outputs. this is to limit noise generated by quickly switching output signals. the slew rate is factory set to approximately 10 ns rise and fall times. port pin input data port latch data p n vdd figure 22- 3 : push - pull output 22.4 input only mode t he input only port c onfiguation is show in figure 2 1 - 4, it is a schmitt - triggered input or ttl input.
preliminary n 79 e352/n79e352r data sheet - 114 - port pin input data schmitt-triggered or ttl figure 22- 4 : push - pull output
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 115 - revision a0 6 23. oscillator n79e352(r) provide s thre e oscillator input option. these are configured at config register (config0) that include on - chip rc oscillator option, external clock input option and crystal oscillator input option. the crystal oscillator input frequency may be supported from 4mhz to 2 4 mhz, and without capacitor or resister. fcpu oscillating circuit xtal1 xtal2 external xtal 1/2 1 0 fs1 (config1.5) internal oscillator (~20khz) bod wdt for bod in power -saving mode pwm, i2c fosc f rc22m timers, uart 00 ext clock 10 11 f osc1 f osc0 cpu clock rate select isp internal oscillator (22.1184mhz) f rc11m cd0 cd1 pmr[1:0] figure 23- 1 : oscillator 23.1 on - chip rc oscillator option the on - c hip rc oscillator is fixed at 11.0592 mhz or 22.1184 mhz (selectable by fs1 co nfig bit) 2 % for n79e352r, 25% for n79e352 frequency to support clock source. when fosc1, fosc0 = 0 1 b, the on - chip rc oscillator is enabled. 23.2 external clock input option the clock source pin (xtal1) is fr o m external clock input by fosc1, fosc0 = 11b, and frequency range is ffrom 0hz up to 2 4 mhz. the device supports a clock output function when either the on - chip rc oscillator or external clock input options are selected. this allows external devices to synchronize to the device. when enabled, via the enc lk bit in the p5m1 register, the clock output appears on the xtal2/clkout pin whenever the on - chip oscillator is running, including in idle mode. the frequency of the clock output is 1/4 of the cpu clock rate. if the clock output is not needed in idle mode , it may be turned off prior to entering
preliminary n 79 e352/n79e352r data sheet - 116 - idle, saving additional power. the clock output may also be enabled when the external clock input option is selected. 23.3 cpu clock rate select the cpu clock of n79e352(r) may be selected by the pmr.cd0/1 bits. if (cd1 ,cd0) = 01b , the cpu clock is running at 4 cpu clock per machine cycle, and without any divi sion from source clock (fosc). t his frequency divi sion function affect all peripheral timings as they are all sourcing from the cpu clock(fcpu). the following table shows the pmr. cd1/0 bits definition. cd1, cd0 clocks/machine cycle 0 x 4 1 0 64 1 1 1024 cd0/1 definitions
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 117 - revision a0 6 24. power monitoring in order to prevent incorrect operation during power up and power drop, the n79e352(r) provide s two power monitor function th at are power - on detect and brownout detect. 24.1 power on detect the power ? on detect function is a design to detect power up after power voltage reaches to a level where brownout detect can work. afte r power on detect, the por (wdcon.6 ) will be set to ?1? to in dicate an initial power up condition. the por flag will be cleared by software. 24.2 brownout detect and reset the n79e352(r) has an on - chip brown - out detection circuit for monitoring the v dd level during operation by comparing it to a programmable brownout tr igger level. the re are 4 brownout trigger levels available for wide r voltage applications . t he 3 nominal levels are 2.6 v, 3.8v and 4.5v (programmable through bov .1 - 0 bits). when v dd drops to the selected brownout trigger level (v bor ), the brownout detectio n logics will either reset the cpu until the v dd voltage raises above v bor or requests a brownout interrupt at the moment that v dd falls and raises through v bor . the brownout detection circuits also provides a low power brownout detection mode for power sa ving. when lpbov=1, the brownout detection repeatly senses the voltage for 64/f brc then turn off detector for 960/f brc (f brc = internal rc frequency), if v dd voltage still below brownout trigger level. f brc , the frequency of built - in rc oscillator is appro ximately 20khz +/ - 100% . the brownout detect block is shown in figure 24- 1 . bov1 bov0 brownout voltage 0 x brownout voltage is 2.6 v 1 0 brownout voltage is 3.8v 1 1 brownout voltage is 4.5v brownout voltage sele ction brownout detect circuit 0 1 bof to reset to brownout interrupt bov[1:0] bod lpbov boi bos figure 24- 1 : brown - out detect block
preliminary n 79 e352/n79e352r data sheet - 118 - vbor+ vbor - v dd boi=0 to select brown-out reset set by hardware clear by software boi=1 to select brown-out interrupt clear by software t bor : brown-out reset delay time with about 8ms nominal brown- out voltage brown-out status bos t bor 8ms reset bof figure 24- 2 : brown - out voltage detection
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 119 - revision a0 6 25. icp(in - circ uit program) flash p rogram the icp(in - circuit - program) mode is another approach to access the flash eprom. there are only 3 pins needed to perform the icp function. one is mode input, shared with rst pin, which must be kept in vdd voltage in the entire icp working period. one is clock input, shared with p1.7, which accepts serial clock from external device. another is data i/o pin, shared with p1.6, that an external icp program tool shifts in/out data via p1.6 synchronized with clock( p1.7 ) to access the fla sh eprom of n79e352(r) . (note, while prhi=0, p1.6, p1.7 are still quasi high during reset period. during reset period , p1.6, p1.7 cann ? t switch to open - drain by setting config). n79e352(r) rst p1.6 p1.7 vdd vss to i/o pin to i/o pin to reset or input pin vdd vpp data clock vss icp program tool vcc jumper icp connector system board icp power jumper figure 26- 1 : icp writer tool connector pin assign note: 1. when using icp to upgrade code, the rst, p1.6 and p1.7 must be taken within design system board. 2. after program finished by icp, to suggest system power must power off and remove icp connector th en power on. 3. it is recommended that user performs erase function and programming configure bits continuously without any interruption. 4. during icp mode, all pwm pins will be tri - stated.
preliminary n 79 e352/n79e352r data sheet - 120 - 26. config bits the n79e352(r) has two config bits (config0 located at fb 00h, config1 located at fb01h) that must be defined at power up and can not be set the program after start of execution. those features are configured through the use of two flash eprom bytes, and the flash eprom can be programmed and verified repeatedly. until the code inside the flash eprom is confirmed ok, the code can be protected. the protection of flash eprom (config1) and those operations on it are described below. 26.1 config0 wdtck pmode prhi bpfr fosc 1 fosc 0 7 6 5 4 3 2 1 0 wdtck : watchdog timer clock selection bit. prhi : port reset high bit. cbod : config brownout detect enable bit. fosc1 : cpu oscillator type select bit 1. fosc0 : cpu oscillator type select bit 0. bpfr : bypass clock filter bit. pmode : port mode bit. cbod - figure 25- 1 : config0 register bits bit name function 7 wdt ck clock source of watchdog timer select bit: 0: the internal 2 0khz rc oscillator clock is for watchdog timer clock used. 1: the uc clock is for watchdog timer clock used. 6 p mode port mode type select bit: 0: port 1~3 and 5 reset to open drain mode. 1: port 1~3 and 5 reset to quasi mode. 5 prhi port reset high or low select bit: 0: port reset to low state. 1: port reset to high state. note: for product to run external program (/ea=0), user ne ed to ensure prhi is set to 1. 4 - reserved. 3 cbod config brownout detect enable bit 0: disable brownout detect. 1: enable brownout detect. 2 bpfr bypass clock filter. 0: disable clock filter. 1: enable clock filter. 1 fosc1 cpu oscillator type s elec t bit 1.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 121 - revision a0 6 0 fosc0 cpu oscillator type s elect bit 0. oscillator configuration bits: fosc1 fosc0 osc source 0 0 4mhz ~ 2 4 mhz crystal 0 1 internal rc oscillator (fs1 bit in co nfig1.5 will determine either 11.0592mhz or 22.1184 mhz) 1 0 reserved 1 1 exter nal oscillator in xtal1 ; x al t2 is in tri - state 26.2 config1 7 6 5 4 3 2 1 0 c6 c7 fs1 c7 : 8/4k flash eprom code lock bit c6 : 512/256/128/64 byte data lock bit fs1 : internal rc 11.0592mhz/22.1184mhz selection bit c1 - cbov.1-0 cbov.1-0 : brownout level selection bits c1 : movc inhibit enable bit - figure 25- 2 : config1 register bits c7: 8 k flash ep rom lock bit this bit is used to protect the customer?s program code. it may be set after the programmer finishes the programming and verifies sequence. once this bit is set to logic 0, both the flash eprom data and config registers can not be accessed again. c6: 128 byte data flash eprom lock bit this bit is used to protec t the customer?s 128 bytes of data code. it may be set after the programmer finishes the programming and verifies sequence. once this bit is set to logic 0, both the 128 bytes of flash eprom data and config registers can not be accessed again. bit 7 bit 6 function description 1 1 both security of 8 kb program code and 128 bytes data area are not lock ed. they can be erased, programmed or read by writer or jtag mode . 0 1 the 8 kb program code area is lock ed. i t can not be read and written by writer or jtag m ode . the 128 bytes data area can be program or read. the bank erase is invalid. 1 0 not support ed. 0 0 both security of 8 kb program code and 128 bytes data area are locked . they can not be read and written by write r or jtag mode . fs1: internal oscilla to r selection bit this bit is used to select internal oscillator.
preliminary n 79 e352/n79e352r data sheet - 122 - fs1 internal oscillator output 0 11.0592 mhz 1 22.1184 mhz (default) internal oscillator selection table cbov.1 - 0: brownout level selection bits these bits are used to select brownout voltage level. c bov . 1 c bov . 0 brownout voltage 1 x brownout voltage is 2.6 v 0 1 brownout voltage is 3.8v 0 0 brownout voltage is 4.5v c1: movc inhibit enable bit movc inhibit enable bit movc access 0 the movc in s truction in external memory cannot access the c ode in internal memory. 1 no restriction. this bit is used to restrict the accessible region of the movc instruction. it can prevent the movc instruction in external program memory from reading the internal program code. when this bit is set to logic 0, a movc instruction in external program memory space will be able to access code only in the external memory, not in the internal memory. a movc instruction in internal program memory space will always be able to access the rom data in both internal and ex ternal memory. if this bit is logic 1, there are no restrictions on the movc instruction.
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 123 - revision a0 6 27. electrical character istics 27.1 absolute maximum ratings symbol parameter condition rating unit dc power supply vdd ? vss - 0.3 +7.0 v input voltage vin vss- 0.3 vdd+0.3 v operating temperature ta - 40 +85 c storage temperature tst - 55 +150 c sink current isk 90 ma note: exposure to conditions beyond those listed under absolute maximum ratings may adversely affects the lift and reliability of the device.
preliminary n 79 e352/n79e352r data sheet - 124 - 27.2 d . c . characte ristics ( ta = - 40~85 c, unless otherwise specified.) parameter sym. specification test conditions min. typ. max. unit operating voltage v dd 2.4 5.5 v v dd = 4.5 v ~ 5.5v @ 24mh z v dd =2. 7 v ~ 5.5v @ 12 mhz v dd =2.4v ~ 5.5v @ 4mhz operating current i dd1 5 m a no load, rst = v dd , v dd = 3.0v @ 11 . 0592mh z i dd2 1 5 ma no load, rst = v dd , v dd = 5 .0v @ 22.1184 mh z idle current i idle 4 ma no load, v dd = 3.0v @ 11 . 0592mh z power down current i pwdn 1 5 a no load, v dd = 5.5v @ disable bov function 1 5 ua no lo ad, v dd = 3.0v @ disable bov function input / output input current p0, p1, p2, p3, p4, p5 i in 1 -5 0 - +10 a v dd = 5.5v , v in = 0v or v in = v dd input current p1.5(rst pin) [1] i in 2 -48 -32 -24 a v dd = 5.5v , v in = 0 .45v input leakage current p0, p1, p2, p3, p5 (open drain) i lk -10 - +10 a v dd = 5.5v, 0 preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 125 - revision a0 6 v il22 - 0.7 0.8 v v dd =2.7v input high voltage rst [*1] v ih21 3.5 2.3 vdd+0.2 v v dd =5.5v v ih22 2 1.5 vdd+0.2 v v dd =2.7v source current p0, p1, p2, p3, p5 ( push - pull mode) i sr1 -1 6 -26 -36 ma v dd = 4.5v, v s = 2.4v -5 - 7.9 -11 ma v dd = 2. 4v, v s = 2.0 v source current p0, p1, p2, p3, p4, p5 (quasi - bidirectional mode) i sr2 -1 5 0 -210 -360 a v dd = 4.5v, v s = 2.4v -39 -53 -69 a v dd = 2. 4v, v s = 2.0 v s ink current p0, p1, p2, p3, p4, p5 (quasi - bidirectional an d push - pull mode) i sk2 13 18.5 24 ma v dd = 4.5v, v s = 0 .4 5 v 9 15 21 v dd = 2. 4v, v s = 0 .4 5 v brownout voltage with bov[1:0] = 0 x b v bo2.4 2.55 2. 6 2.85 v brownout voltage with bov[1:0] =10b v bo3.8 3.65 3.8 3.95 v brownout voltage with bov[1:0] =11b v b o4.5 4.35 4.5 4.65 v hysterisis range of bod voltage v b h 35 - 150 mv v dd = 2.4v ~5.5 v, (lpbod,boi) = (0,x) or (1,0) 10 - 60 mv v dd = 2.4v ~5.5 v, (lpbod,boi)=(1,1) sink current [*2] p0, p2, ale, /psen isk31 -1 6 -26 -36 ma v dd =4.5v, vs = 0.45v isk32 -5 - 7.9 -11 ma v dd =2.7v, vs = 0.45v source current [*2] p0, p2, ale, /psen isr31 13 18.5 24 ma v dd =4.5v, vs = 2.4v isr32 9 15 21 ma v dd =2.7v, vs = 2.0v notes: *1. rst pin is a schmitt trigger input. rst has internal pull - low resistor. *2. xtal1 is a cmos input. *3. pins of p0, p1 , p2 , p3 and p5 can source a transition current when they are being externally driven from 1 to 0. the transition current reaches its maximum value when vin approximates to 2v. 27.3 a . c . characteristics t clcl t clcx t chcx t clch t chcl note: duty cycle is 50%.
preliminary n 79 e352/n79e352r data sheet - 126 - 27.3.1 external clock c haracteristics parameter symbol min. typ. max. units notes clock high time t chcx 22.6 - - ns clock low time t clcx 22.6 - - ns clock rise time t clch - - 10 ns clock fall time t chcl - - 10 ns 27.3.2 ac s pecification parameter symbol variable clock min. variable clock max. units oscillator frequency 1/t clcl 0 24 mhz 27.3.3 external clock characteristics parameter symbol min typ max units notes clock high time t chcx 12.5 ns clock low time t clcx 12.5 n s clock rise time t clch 10 ns clock fall time t clcl 10 ns t clcl t clcx t chcx t clch t chcl note: duty cycle is 50% figure 26- 1 external clock characteristics 27.3.4 serial port mode 0 timing characteristics parameter symbol min typ max units notes serial port clock cycle time sm2=0 12 clocks per cycle sm2=1 4 clocks per cycle t xlxl 12 t clcl 4 t clcl ns output data setup to clock rising edge sm2=0 12 clocks per cycle sm2=1 4 clocks per cycle t qvxh 10 t clcl 3 t clcl ns
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 127 - revision a0 6 output data hold to clock rising edge sm2=0 12 clocks per cycle sm2=1 4 clocks per cycle t xhqx 2 t clcl t clcl ns input data hold after clock rising sm2=0 12 clocks per cycle sm2=1 4 clocks per cycle t xhdx t clcl t clcl ns clock ri sing edge to input data valid sm2=0 12 clocks per cycle sm2=1 4 clocks per cycle t xhdv 11 t clcl 3 t clcl ns 27.3.5 p rogram m emory r ead c ycle t llax 1 t pxiz t plaz t llpl t pxix t pliv t aviv 2 t aviv 1 t plph t avll address a8-15 address a8-15 address a 0 - a 7 instruction in address a 0 - a 7 port2 port0 psen ale t lliv t lhll figure 26- 2 program memory read cycle
preliminary n 79 e352/n79e352r data sheet - 128 - 27.3.6 d ata m emory r ead c ycle t avll t avwl 1 t llax 1 t whlh t rldv t rlrh t rlaz t rhdz t rhdx t avdv 2 t avdv 1 t llwl address a 0 - a 7 instruction in data in address a 0 - a 7 t lldv port2 port0 psen ale rd address a8-15 figure 26- 3 data memory read cycle 27.3.7 data m emory write c ycle t avll t avwl 1 t llax 2 t whlh t wlwh t qvwx t whqx t avdv 2 t llwl instruction in data out address a 0 - a 7 address a 0 - a 7 port2 port0 psen ale wr address a8-15 figure 26- 4 data me mory write cycle
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 129 - revision a0 6 27.3.8 i2c bus timing characteristics parameter symbol standard mode i2c bus unit min. max. scl clock frequency f scl 0 100 khz bus free time between a stop and start condition t buf 4.7 - us hold time (repeated) start condition. after this period, the first clock pulse is generated t hd;sta 4.0 - us low period of the scl clock t low 4.7 - us high period of the scl clock t high 4.0 - us set - up time for a repeated start condition t su;sta 4.7 - us data hold time t hd;dat 5.0 - us data set - up time t su;dat 250 - ns rise time of both sda and scl signals t r - 1000 ns fall time of both sda and scl signals t f - 300 ns set - up time for stop condition t su;sto 4.0 - us capacitive load for each bus line c b - 400 pf t buf stop sda scl start t hd;sta t low t hd;dat t high t f t su;dat repeated start t su;sta t su;sto stop t r fi gure 26- 5 : i2c bus timing explanation of logic symbols in order to maintain compatibility with the original 8051 family, this device specifies the same parameter as such device, using the same symbols. the ex planation of the symbols is as follows. t time a address c clock d input data h logic level high l logic level low i instruction p psen q output data r rd signal v valid w wr signal x no longe r a valid state z tri - state
preliminary n 79 e352/n79e352r data sheet - 130 - 27.4 rc osc and ac characteristics (vdd ? vss = 2. 4 ~5v, ta = - 40~85 c.) parameter specification (reference) test conditions min. typ. max. unit frequency accuracy of on - chip rc oscillator ( for n79e352 ) - 25 25 % v dd = 2.4v~5.5v , ta = -40c ~8 5 c frequency accuracy of on - chip rc oscillator with calibration 1 ( for n79e352r ) - 2 2 % v dd = 4.5v~5.5v , ta = 2 5 c - 5 5 % v dd = 2 .7 v~ 5 .5 v, ta = 0 ~85 c - 7 7 % v dd = 2.7 v~ 5 .5 v, ta = -20 ~85 c - 9 9 % v dd = 2.7 v~ 5 .5 v, ta = -40 ~85 c wakeup t ime 256 clk note: 1. these values are for design guidance only and are not tested. 27.5 typical application c ircuit crystal c1 c2 r 4mhz ~ 24 mhz without without without the above table shows the reference values for crystal applications. xtal2 xtal1 c1 c2 r n79e352(r)
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 131 - revision a0 6 28. package dimensions 28.1 40- pin dip 1.37 1.22 0.054 0.048 symbol min nom max max nom min dimension in inch dimension in mm a b c d e a l s a a 1 2 e 0.050 1.27 0.210 5.33 0.010 0.150 0.016 0.155 0.018 0.160 0.022 3.81 0.41 0.25 3.94 0.46 4.06 0.56 0.008 0.120 0.670 0.010 0.130 0.014 0.140 0.20 3.05 0.25 3.30 0.36 3.56 0.540 0.550 0.545 13.72 13.97 13.84 17.02 15.24 14.99 15.49 0.600 0.590 0.610 2.29 2.54 2.79 0.090 0.100 0.110 b 1 1 e e 1 2.055 2.070 52.20 52.58 0 15 0.090 2.29 0.650 0.630 16.00 16.51 15 0 seating plane e a 2 a c e base plane 1 a 1 e l a s 1 e d 1 b b 40 21 20 1
preliminary n 79 e352/n79e352r data sheet - 132 - 28.2 44- pin plcc 44 40 39 29 28 18 17 7 6 1 l c 1 b 2 a h d d e b e h e y a a 1 seating plane d g g e symbol min nom max max nom min dimension in inch dimension in mm a b c d e h e l y a a 1 2 e b 1 h d g g d e 0.020 0.145 0.026 0.016 0.008 0.648 0.590 0.680 0.090 0.150 0.028 0.018 0.010 0.653 0.610 0.690 0.100 0.050 bsc 0.185 0.155 0.032 0.022 0.014 0.658 0.630 0.700 0.110 0.004 0.51 3.68 0.66 0.41 0.20 16.46 14.99 17.27 2.29 3.81 0.71 0.46 0.25 16.59 15.49 17.53 2.54 1.27 4.70 3.94 0.81 0.56 0.36 16.71 16.00 17.78 2.79 0.10 bsc 16.71 16.59 16.46 0.658 0.653 0.648 16.00 15.49 14.99 0.630 0.610 0.590 17.78 17.53 17.27 0.700 0.690 0.680
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 133 - revision a0 6 28.3 44- pin pqfp 0.25 0.10 0.010 0.004 symbol min nom max max nom min dimension in inch dimension in mm a b c d e h d h e l y 0 a a l 1 1 2 e 0.006 0.15 - - 0.002 0.075 0.01 0.081 0.014 0.087 0.018 1.90 0.25 0.05 2.05 0.35 2.20 0.45 0.390 0.510 0.025 0.063 0.004 0 10 0.394 0.520 0.031 0.398 0.530 0.037 9.9 0.80 12.95 0.65 1.60 10.00 13.20 0.8 10.1 13.45 0.95 0.398 0.394 0.390 0.530 0.520 0.510 13.45 13.20 12.95 10.1 10.00 9.9 10 0 0.10 .0315 0.01 0.02 0.25 0.5 seating plane 11 22 12 see detail f e b a y 1 a a 2 l l 1 c e e h 1 d 44 h d 34 33 detail f
preliminary n 79 e352/n79e352r data sheet - 134 - 28.4 48- pin lqfp
preliminary n79e352/n79e352r data sheet publication release date: jul, 29 , 200 9 - 135 - revision a0 6 29. revision history version date page d escription a 0 1 aug , 14 , 2008 - initial issued a 02 aug, 21 , 2008 7,8 u pdate pin configurations. a03 feb , 2 , 200 9 - a dd access external memory diagram a 04 feb , 9, 2009 - m odify the part no . with each package 1. 40dip: n79e352adg, n79e352radg 2. 44plcc: n 79e352apg, N79E352RAPG 3. 44pqfp: n79e352afg, n79e352rafg 4. 48lqfp: n79e352alg, n79e352ralg a05 apr, 22 , 2009 - 108~109 124 ~ 125 115 1. correct typo errors. 2. release input capture 0 function in section 20. 3. re - arrange section sequency after section 20. 2. update d.c specification. 3. renew figure 0 - 1 : oscillator a06 jul, 29, 2009 119 1. add icp description. important notice nuvoton products are neither intended nor warranted for usage in systems or equipment, any malfunction or failure of which may cause loss of human life, bodily injury or severe property damage. such applications are deemed , ?insecure usage?. insecure usage includes, but is not limited to: equipment for surgical implementation, at omic energy control instruments, airplane or spaceship instruments, the control or operation of dynamic, brake or safety systems designed for vehicular use, traffic signal instruments, all types of safety devices, and other applications intended to support or sustain life. all insecure usage shall be made at customer?s risk, and in the event that third parties lay claims to nuvoton as a result of customer?s insecure usage, customer shall indemnify the damages and liabilities thus incurred by nuvoton.


▲Up To Search▲   

 
Price & Availability of N79E352RAPG

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X